我对rails/ruby/bundler还是个新手,有点困惑。
在我们的 config/application.rb
文件中,有这个 bundler 段:
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
在我们的Gemfile
中,我们使用不同的组,例如
group :development, :test do
gem "rspec-rails", ">= 2.7.0", :group => [:development, :test]
gem 'shoulda-matchers'
gem 'watchr'
gem 'spork', '~> 1.0rc'
gem 'spectator'
gem 'debugger'
gem 'wirble'
end
但是当我运行RAILS_ENV=生产 bundle 安装
(或bundle install --deployment
)时,它仍然安装来自开发/测试组的gems...
为什么会发生这种情况或者如何才能使其正常工作?
最佳答案
看看--without
选项:
bundle 安装——无需开发测试
默认情况下,Bundler 会安装所有 gem,并且您的应用程序会使用它需要的 gem。 Bundler 本身对 Rails 和当前环境一无所知。
关于ruby-on-rails-3 - Rails bundle 仅安装生产,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10912614/