这可能是Bundler上一个非常“新手”的问题,但我想知道bundle install如何知道使用什么环境或如何设置它?或者我甚至需要?我的问题是我按照环境对Gem(Gemfile)进行了分组,现在部署时我只想安装生产宝石。
答案 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
标记。
答案 1 :(得分:0)
您可以在gem deependency声明中使用“group”选项。检查此ASCIICast:http://asciicasts.com/episodes/201-bundler