views:

47

answers:

1

Hello,

I was hoping someone could suggest some best practices for configuring Rails applications using a database (i.e. persisting configuration settings to a database rather than a flat file). My reasoning for this is that I have an application that will run on multiple servers and there are some configuration settings that are fairly dynamic and I would want to change them without having to make a change on every server.

In other languages, I've seen this done by using a simple configuration table (like name/value pairs) and a singleton that exposes the configuration data and periodically gets refreshed. Is there a similar - or better - way to do this with Rails?

Thanks in advance.

+1  A: 

Not the prettiest solution I'm sure, but one thing we've done for our internal apps is create a 'config' field that is simply a text field containing a serialized hash. Then we deserialize on load from the db.

rainkinz
Thanks for the suggestion. Do you use the ApplicationHelper module to query/deserialize/provide getter-type methods to the configuration hash? Or is there a better approach?
Chris Hart