Skip to main content

environment_specific_config

🌐 Environment‑Specific Error Reporting and Caching

Fine‑tune Rails behavior per environment by editing config/environments/*.rb. For example, you might disable full error reports in staging but keep caching off to aid debugging:

# config/environments/staging.rb
Rails.application.configure do
# Treat staging like production for error pages
config.consider_all_requests_local = false
config.action_dispatch.show_exceptions = true

# Enable caching to test performance
config.action_controller.perform_caching = true
config.cache_store = :memory_store
end

Meanwhile, in development you typically have:

# config/environments/development.rb
Rails.application.configure do
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
end

This approach ensures each environment behaves appropriately without extra conditional logic scattered across the codebase.