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! -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060404/2e56da70/attachment.html
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? On 4/4/06, Brian Hogan <bphogan@gmail.com> wrote:> > 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! > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060405/bbc940b5/attachment.html
Brian Hogan 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 :( 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 :) Thanks -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---