【问题标题】:How to permanently change Gemfile in each new rails app如何在每个新的 Rails 应用程序中永久更改 Gemfile
【发布时间】:2013-08-05 05:53:54
【问题描述】:

当我创建一个新的 Rails 应用程序时,如何永久更改 Gemfile 中的内容。

我遇到的问题是,每次我创建一个新的 rails 应用程序时,当我在应用程序内部运行 'rails server' 时,我都会得到一个 execjs error。在stackoverflow上搜索了几个小时可能是什么问题后,我发现'therubyracer'在每次创建新的rails应用程序时默认在Gemfile中被“#”注释掉。

如何永久更改 Gemfile,以便我可以摆脱 'gem therubyracer' 前面的 '#' 一次,这样我就不必每次创建新的 rails 应用程序时都打开 Gemfile摆脱'#'

【问题讨论】:

    标签: ruby-on-rails ruby gemfile therubyracer


    【解决方案1】:

    【讨论】:

    • 不完全是,我不希望它要求用户输入是或否来放入 gem,我只想永久摆脱'#'这样我就不会'每次我制作一个新的 Rails 应用程序时,都不必在 Gemfile 中删除它。
    • @user43564,您不需要提问。您是否按照模板详细信息链接:guides.rubyonrails.org/rails_application_templates.html。请参阅第 2.1 节。
    【解决方案2】:

    您可以使用nodejs 作为 javascript 运行时,它在内存中比 ruby​​racer 更好。 execjs error 将被固定为具有默认 Gemfile 的任意数量的项目。

    这就是你在 Ubuntu 中的安装方式

    sudo apt-get install python-software-properties
    sudo add-apt-repository ppa:chris-lea/node.js
    sudo apt-get update
    sudo apt-get install nodejs nodejs-dev npm
    

    如果您希望您的 Gemfile 每次都包含特定行,则应使用其他答案中建议的模板。要将其设为默认值,您可以将 .railrc 配置为每次都包含该模板。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-24
      • 1970-01-01
      • 1970-01-01
      • 2014-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多