Rails configuration policies
Rails config files tend to get a bit messy, but everywhere I worked they mostly follow a similar set of policies.
There are typically 2 kinds of settings in an app.
Business settings
These settings are “businessy” in nature. Examples: support email, number of days before a user should be logged out, etc. The same setting often spans all environments.
I would normally put these in a config/my_app.yml
file, and set it via config.my_app = config_for(:my_app)
Technical settings
Some config settings are controlled completely by engineers who write the code. These are split into 2 categories:
- Secret settings — encryption keys, api credentials, etc. We probably want to keep these in control of developers in development and test/CI environments. In production, these would typically come from ENV vars. Let’s call them creds.
- Plain settings — feature flags, hostnames, behavior changes between environments. These don’t necessarily need configurability via ENV vars, but they optionally can be.
Update
I have since released the loadout gem to make managing these different settings easier.