Application configuration options

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:

  1. 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

  2. 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.

  3. Use before_filter to put the hash in the user’s session. Users need
    to
    log out to see the changes.

  4. 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!

Hmmm, no takers? Just looking for suggested methods that people have
used to
configure applications. Or is everyone just using a bunch of
non-changeable
constants in the environment file?

Brian H. wrote:

Hmmm, no takers? Just looking for suggested methods that people have
used to
configure applications. Or is everyone just using a bunch of
non-changeable
constants in the environment file?

I just want to look for the same pattern, but still can’t find it :frowning:
Anyway, Brian, with your #2 option can I have a more deep sample about
how you do it? you, in your #2 option, are loading the configs from db
on startup and put them in a hash, then can how do you get the hash in
the application? Sorry if a dumb question, but I a dumb in Ruby :slight_smile:
Thanks