README.rdoc

Settingslogic

Settingslogic is a simple configuration / settings solution that uses an
ERB enabled YAML file. It has been great for our apps, maybe you will enjoy
it too. Settingslogic works with Rails, Sinatra, or any Ruby project.

Name it Settings, name it Config, name it whatever you want. Add as many or
as few as you like. A good place to put this file in a rails app is
app/models/settings.rb

I felt adding a settings file in your app was more straightforward, less
tricky, and more flexible.

2. Create your settings

Notice above we specified an absolute path to our settings file called
“application.yml”. This is just a typical YAML file. Also notice above that
we specified a namespace for our environment. A namespace is just an
optional string that corresponds to a key in the YAML file.

Using a namespace allows us to change our configuration depending on our
environment:

Note: Certain Ruby/Bundler versions include a version of the Psych
YAML parser which incorrectly handles merges (the `<<` in the example
above.) If your default settings seem to be overwriting your
environment-specific settings, including the following lines in your
config/boot.rb file may solve the problem:

This would allow you to specify a custom value for per_page just for posts,
or to fall back to your default value if not specified.

5. Suppressing Exceptions Conditionally

Raising exceptions for missing settings helps highlight configuration
problems. However, in a Rails app it may make sense to suppress this in
production and return nil for missing settings. While it's useful to
stop and highlight an error in development or test environments, this is
often not the right answer for production.