When creating say a cms application where website specific details will vary depending on the website, where should I be storing this information?
Things like: site name, support email, smtp settings, etc.?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you mean configuration data for the application, here’s what I do:
I create a
config/app_config.ymlfile with my config information, like this:Then, at the top of
config/application.rb(right below the first ‘require’ statement), I add this:Now, any time I need to access the configuration data, I can get to it via the APP_CONFIG hash, like so:
Note, the above is for Rails 3. For rails 2, instead of loading the config in application.rb, you would put the statements into config/preinitializer.rb.
See http://asciicasts.com/episodes/226-upgrading-to-rails-3-part-2 for more details.