I’ve been kicking this around for months and I thought I would finally
ask
the list and see if I can get some opinions.
I want a database table that holds configuration options for my system.
Think exmail server address, port, maybe a path for a banner image,
things
liike that. The way i’ve implemented it is a single column, each column
is
a value. This maps very nicely to a configuration model.
@config = Config.find(1)
@config.smtp_server = ‘smtp.mydomain.com’
…
Noiw, what’s the best way to make this available to the application?
Here
are my options:
-
Get the configuration on every request using a before_filtter
Don’t like this because it always hits the DB, but it is always
current -
Load it up on application startup by populating this through
environment.rb into a hash…
. fastest method, but then it never gets refreshed until the app is
reloaded. -
Use before_filter to put the hash in the user’s session. Users need
to
log out to see the changes. -
Do #2 but update the value of the constant when the data changes,
possibly by using a cache sweeperr observer pattern?
Not sure if I like this or not…
I would love to hear some other options! Please share!