DHH mentioned in the Rails 4.1 announcement blog post that it now supports configuration of database connetions through URLs. I couldn’t find any documentation for the feature so here’s how it works.
Your config/database.yml can now go from something like this:
You can also specifiy the database URL as an environment variable when running your app, for example:
Unfortunately you can only override an existing config with an env var if you use the original (non url based) syntax in your database.yml file.
Configuration via env var is very useful in production environments where service discovery is used and saves having to rewriting the database.yml each time just to point at a different database.