Recently, I ran into a useful way to store your base database properties, and override them per development environment. This approach is really useful, so I thought I would blog about it.

Here is an example config/database.yml file which implements the aforementioned approach:

login: &login
  adapter: mysql
  username: _your_username_
  password: _your_password_
  host: mysql.yourdomain.com
  socket: /var/run/mysqld/mysqld.sock

development:
  < <: *login
  database: myclient_dev

test:
  <<: *login
  database: myclient_test

production:
  <<: *login
  host: mysql.myclient.com
  database: myclient