Default environment specific values for DATABASE_URL
Apr 11, 2012
If you've been following the intelligent advice from 12 Factor
when building your application then you'll know that environment variables
are the correct place to specify settings for your environment. Crazy eh?
However this is at odds with the assumptions and conventions in Rails that
database.yml is the canonical source of all your database configs. Having
to export your environment variables any time you want to change
the environment of the app, or over-riding in
is needless pain.
Keeping DATABASE_URL and database.yml consistent
Instead of having to manage all this manually, lets just let Rails win
for now by setting
DATABASE_URL to the value(s) defined within
No more having to set default values in your helpers, no more re-exporting
your environment locally when you want to change modes, no more exports
if you're using libraries that assume you're configuring your app in an
intelligent and scalable way (like queue_classic).
Add this to your
That's it. Source is on GitHub, pull requests
gladly accepted if you find any bugs.