Bundler如何知道使用什么环境?

时间:2010-12-13 08:10:50

标签: ruby-on-rails bundler ruby-on-rails-3

这可能是Bundler上一个非常“新手”的问题,但我想知道bundle install如何知道使用什么环境或如何设置它?或者我甚至需要?我的问题是我按照环境对Gem(Gemfile)进行了分组,现在部署时我只想安装生产宝石。

2 个答案:

答案 0 :(得分:28)

application.rb文件的顶部,您可以看到

# If you have a Gemfile, require the gems listed there, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(:default, Rails.env) if defined?(Bundler)

启动Rails时,Bundler会自动加载:default组和当前环境的所有依赖项。

请注意,当您运行bundle install时,Bundler会解析并安装所有环境的依赖项,除非您指定--without option

$ bundle install --without staging development test

在制作中,您可能还想添加--deployment标记。

More info about bundle install

答案 1 :(得分:0)

您可以在gem deependency声明中使用“group”选项。检查此ASCIICast:http://asciicasts.com/episodes/201-bundler