Technical recipes for frequently and infrequently recurring problems
We use dotenv to manage our environment variables, in dev, test, and production. In your code, wherever you have a value that shouldn’t be checked into version control (e.g., a password), or a value that will vary depending on server name (e.g., a URL config for rails), put it in an environment variable instead and reference it by calling ENV['WHATEVER']
in your code.
dotenv-rails
to your gemfile at the top level. Do not restrict it to only being in the dev and test groups. Run bundle install
dotenv.sample
in the root of your project. You’ll populate this with empty values for every environment variable you end up setting, so a new user of the project has a starting place..env.development
to hold your local development settings.env.test
for local and CI testing settings.env.production
to hold the settings for the production server(s).env.development
, .env.test
and .env.production
to .gitignore