My staging and production environment Rails configuration are 99% the same with just a few things set differently (e.g. the log level), and I'd really like to eliminate the duplication between the two environment files.
For example, I have something like this:
# config/environments/staging.rb MyApp::Application.configure do config.cache_classes = true config.static_cache_control = "public, max-age=31536000" config.log_level = :debug # ... end # config/environments/production.rb MyApp::Application.configure do config.cache_classes = true config.static_cache_control = "public, max-age=31536000" config.log_level = :info # ... end
Any recommendations on the best way to create a shared configuration that doesn't also affect my development environment?
In my projects, I have 3 production-like environments so I have a file called shared_production.rb under config/environments
where I put the common configuration
MyApp::Application.configure do config.cache_classes = true config.consider_all_requests_local = false #more shared configs end
And then in each environment specific config file (production.rb, staging.rb, testing.rb) I do
require File.expand_path('../shared_production', __FILE__) MyApp::Application.configure do config.log_level = :debug #more environment specific configs end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With