module Rails::Generators::Actions
def environment(data = nil, options = {})
end
%(config.asset_host = "localhost:3000")
environment(nil, env: "development") do
end
%(config.asset_host = "cdn.provider.com")
environment do
The code can also be specified as the return value of the block:
corresponding file in +config/environments+.
+:env+ can also be an array. In which case, the code is added to each
end
# ...
config.asset_host = "localhost:3000"
Rails.application.configure do
# config/environments/development.rb
Results in:
environment %(config.asset_host = "localhost:3000"), env: "development"
corresponding file in +config/environments+ instead.
If the +:env+ option is specified, the code will be added to the
end
# ...
config.asset_host = "cdn.provider.com"
class Application < Rails::Application
# config/application.rb
Results in:
environment %(config.asset_host = "cdn.provider.com")
+config/application.rb+ so that it applies to all environments.
By default, adds code inside the +Application+ class in
Adds configuration code to a Rails runtime environment.
def environment(data = nil, options = {}) sentinel = "class Application < Rails::Application\n" env_file_sentinel = "Rails.application.configure do\n" data ||= yield if block_given? in_root do if options[:env].nil? inject_into_file "config/application.rb", optimize_indentation(data, 4), after: sentinel, verbose: false else Array(options[:env]).each do |env| inject_into_file "config/environments/#{env}.rb", optimize_indentation(data, 2), after: env_file_sentinel, verbose: false end end end end