I have a relatively simple Rails app and I would like to store various configuration settings that administrator users can change whilst the application is running, for example, allowing comments on posts or changing the display format of the date.
I know I can store constants etc in the environment.rb file, however these appear to be loaded only when the server is restarted.
Is there an alternative place I can define this information or would it be better to keep it in the database?
Any advice appreciated.
Thanks.
You can use database. Create a separate table “settings” that stores key/value parameters you need. The downside of this solution is a performance hit (querying DB every time you need a setting). To fix this issue you could you read/write through cache like “cache_money” or create your own by using “Rails.cache”