I am working on a Rails application that has user authentication which provides an administrators account. Within the administrators account I have made a page for sitewide settings.
I was wondering what the norm is for creating these settings. Say for example I would like one of the settings to be to change the name of the application name, or change a colour of the header.
What I am looking for is for someone to explain the basic process/method – not necessarily specific code – although that would be great!
For general application configuration that doesn’t need to be stored in a database table, I like to create a
config.ymlfile within the config directory. For your example, it might look like this:This configuration file gets loaded from a custom initializer in config/initializers:
Rails 2.x:
Rails 3.x:
You can then retrieve the value using:
See this Railscast for full details.