Thoughts, links, pictures on music, food, wine, film, tech etc.


I wrote this:

behavior: a Rails gem/plugin for storing application configuration in the database.

I just pushed out "behavior", a Rails gem/plugin for storing application settings / configuration variables in the database.

I needed a solution like this after working on the Rails Development Directory. As it's now open source, we can't store any configuration variables such as the "from:" email address or passwords in the source code. There are solutions that read from a site_config.yml, but that's tricky for end users to edit, and also introduces headaches for deploying.

It's useful to store things like the site title, description, email address and passwords etc. outside of the source code. Keeping them in the database means they're completely decoupled and end users can edit them. Behavior also allows you to set sensible defaults so that your application code can depend on at least something being set, for development and testing.

Behavior uses a Yaml configuration file to define a set of configuration files for your app. You can then access those global config variables with "Behavior.config[:variable]", or just "config[:variable]" in your controllers and views.

It also comes with an in built web interface for managing the variables.

You can check out the source and installation instructions over on github.

Made by Paul Campbell. paul@rushedsunlight.com. Twitter. Github.