markbates/configatron — Issue #24: What is the right / best place to store configatron configuration in a Rails app?
Author: konung
Created: 2011-10-14 01:43:44+00:00
State: open

Hello,
I'm cross-posting this from stackoverflow as I don't seem to get any views on this question ( just 3 in over 24 hours :( ). Anyways I'm trying out configatron for my Rails 3.1 app and it's a great tool (thank you, markbates!) - but here is my question:

I'm using configatron gem for a new Rails app that is backed by ActiveRecord. Some of my configatron settings are set in a file and some are pulled from DB, as they will change from time to time, here are a couple of lines from my configatron.rb

configatron.app.uptime.start = Time.now
configatron.email.signature = Setting.where(:keyname => "email_signature").first.value.to_s unless Setting.where(:keyname => "email_signature").first.nil?

Since this app sends multuple emails from multiple mailers - that is a good way to keep this global config in one place, plus it reduces db lookups for signature. If for some reason site admin decides to change it - they can do it through web admin interface that will update my settings table ( tied to Setting model).

This is all jolly & good, however what is the best place to store configatron.rb? Right now it's sitting in my initializers folder. Which means it will load once on application startup - which is good, however if one of the settings changes - site admin decides to tweek email signature to mention a new promotional website - in order for the change to take effect - I would need to restart app ( I'm running passenger - so it trivial to do `touch tmp/restart.txt` from code). However that means other configatron settings that I don't wont to reset ( such as my uptime start timestamp) will be reset as well, plus if somebody is in a middle of some transaction I will most likely break it.

So what is a better place to move my configatron.rb and load from so that it would allow for
loading once on startup and then changing some configs without and app restart?

Thanks.