Automatically set proper pg_host

For a setup with multiple release nodes database.yml should contain the IP of the database server (not string 'localhost').
Excactly, that way you're checking that all Ruby DB clients are running on the DB host. If so, you can connect to localhost, if not, you use the DB host name.

There is one more alternative, and that is to always use the primary(:db).hostname. However, that requires changing Postgresql config I think (I do that in my multi server setup).