开发者

How does Bundler know what environment to use?

Here's probably a very "newbieish" question on Bundler, but I'm wondering how bundle install knows what environment to use or how to set it? Or do I even need to? My problem is that I've grouped my gems (in Gemfile) by environme开发者_运维知识库nts and when deploying now I only want production gems to be installed.


At the top of the application.rb file you can see

# 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)

When Rails is booted, Bundler automatically loads all the dependencies for the :default group and current environment.

Please note that when you run bundle install, Bundler resolves and install dependencies for all the environments, unless you specify a --without option

$ bundle install --without staging development test

In production, you might also want to add the --deployment flag.

More info about bundle install.


You can use the "group" option in the gem deependency declaration. Check this ASCIICast: http://asciicasts.com/episodes/201-bundler

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜