Topic: Alternatives to using the database.yml file

I'm developing an app that will have the source code hosted in a public repository.  However, I don't want the username/password info from the database.yml file to be available.  At the same time, I'm using Capistrano to deploy, so I think I need that info somewhere to facilitate the automated activity.  Is there another, more secure place to put that information?

Re: Alternatives to using the database.yml file

Sometimes you need to access the database information, such as dsn, database username or password from the databases.yml in your Symfony application. Since databases.yml is just a yml file, you can always find the file, parse the information in the file and read the information you want. Buy prozac

Needless to say this is a very arduous task, even with a yml parser. Furthermore, the fact that there are multiple environments in one single databases.yml can complicated the task of obtaining the correct set of variables.

An alternative way to do it is to use the underlying Symfony library. Suppose that you have the following databases.yml:

Last edited by didyM (2012-07-18 09:01:54)

Re: Alternatives to using the database.yml file

Um, Symfony is a php framework, not a ruby framework, so I'm not sure why I would be using a Symfony library in a RoR app.

At any rate, the solution appears to be to leave the database.yml file out of the repository, but keep a copy tucked away somewhere on the production server, then use a Capistrano task to copy the database.yml into the /config directory after the code update step is complete.  I've set up the Cap task, but have not tried it yet to see if it works.  This same process can then be used for all files that you don't want in the public repository, like secret_token.rb, and keys for things like Facebook integration.