I have remotes set up on Heroku for production and staging.
我在Heroku上设置遥控器进行制作和舞台演出。
On staging I have set the app's envs to include:
在暂存时,我已将应用程序的env设置为包括:
RACK_ENV=staging
RAILS_ENV=staging
I would like to be able to specify a staging
group in my Gemfile
in the same way I can currently use production
, test
or assets
:
我希望能够在我的Gemfile中指定一个临时组,就像我目前使用生产,测试或资产一样:
group :staging do
gem "example", "~> 0.9"
end
I understand how to add custom groups. From my application.rb
:
我了解如何添加自定义组。从我的application.rb:
groups = {
assets: %w(development test)
}
Bundler.require(:security, :model, :view, *Rails.groups(groups))
But how do I add a group that is only loaded in staging?
但是,如何添加仅在分段中加载的组?
I've tried without success:
我试过没有成功:
groups = {
assets: %w(development test),
staging: %(staging)
}
Bundler.require(:security, :model, :view, *Rails.groups(groups))
1 个解决方案
#1
10
Your Gemfile could include a group as follows:
您的Gemfile可以包含如下组:
# Gemfile
group :staging do
gem 'example','~>1.0'
end
Create an environment for staging
为登台创建环境
# /config/environments/staging.rb
...
copy config/environments/production.rb code here with adjustments as needed
...
The reason this works is found in /config/application.rb.
其工作原理可在/config/application.rb中找到。
Rails.groups includes the :default group (all ungrouped gems) and the gem group matching the name of the environment, set by RAILS_ENV, which in this case would be "staging". Your require. Your Bundler.require should look like:
Rails.groups包括:默认组(所有未组合的gems)和与RAILS_ENV设置的环境名称匹配的gem组,在本例中为“staging”。你的要求。您的Bundler.require应如下所示:
Bundler.require *Rails.groups(:assets => %w(development test))
For more info regarding Bundler and groups, read http://bundler.io/v1.5/groups.html
有关Bundler和组的更多信息,请阅读http://bundler.io/v1.5/groups.html
#1
10
Your Gemfile could include a group as follows:
您的Gemfile可以包含如下组:
# Gemfile
group :staging do
gem 'example','~>1.0'
end
Create an environment for staging
为登台创建环境
# /config/environments/staging.rb
...
copy config/environments/production.rb code here with adjustments as needed
...
The reason this works is found in /config/application.rb.
其工作原理可在/config/application.rb中找到。
Rails.groups includes the :default group (all ungrouped gems) and the gem group matching the name of the environment, set by RAILS_ENV, which in this case would be "staging". Your require. Your Bundler.require should look like:
Rails.groups包括:默认组(所有未组合的gems)和与RAILS_ENV设置的环境名称匹配的gem组,在本例中为“staging”。你的要求。您的Bundler.require应如下所示:
Bundler.require *Rails.groups(:assets => %w(development test))
For more info regarding Bundler and groups, read http://bundler.io/v1.5/groups.html
有关Bundler和组的更多信息,请阅读http://bundler.io/v1.5/groups.html