Since the database.yml file is processed by eRB, here’s what I do to keep connection and password information specific to the machine:
==== config/database.yml ====
vvv Copy the following two YAML maps to a file called config/mydatabase.yml
^^^ Copy the previous two YAML maps to a file called config/mydatabase.yml
<%= file = File.join(RAILS_ROOT, “config”, “mydatabase.yml”)
IO.read(file) if File.exist?(file) %>
same for test and production
==== config/mydatabase.yml ====
Note that the YAML maps stay in config/database.yml as the defaults. If the file config/mydatabase.yml exists, it can redefine either or both the ‘login’ or ‘connection’ maps. In this case, my own local one uses the same default username and password for the login, so it’s not redefined. The connection, however, is via a socket on my Mac and there are similar config/mydatabase.yml files on the other development machines and on the staging and production servers.
The config/database.yml file is kept in version control, but the config/mydatabase.yml file is NOT. I have manual backup copies of a TxD-mydatabase.yml and so on for other machines, but the local login and connection information stays only on the machine it is set for.
Rob Biedenharn http://agileconsultingllc.com