Clean your configuration with configuration_manager

If you’re spreading constants around your environments files to configure your Rails apps based on the environment it is running on, stop immediately! Let’s say it’s not very wise… ;)
There’s no point in having lots of different constants all around your code that basically all do the same thing: configure your app.

Instead, you should do something similar to what Geoffrey Grosenbach suggests in Rails Code Review — BTW, we translated that PDF in Italian: have a YAML file in your config directory where you store all of the settings for your app grouped by environment.

I said you should do something similar, because what Geoffrey suggests is just a starting point and that solution can be made a tad more elegant.
Which is what our new plugin is about!

ConfigurationManager allows you to have a single YAML file where you can store all of your settings, then setup a single constant which can be used all over your app by doing something like ConstantName.setting_name; or even ConstantName.group_of_settings.setting_name.

The YAML file should be placed in config/configuration_manager.yml and it should contain your settings like this:

everyone: &every_env
  key1: value1
  inner_hash:
    key2: value2

development: &non_production_env
  <<: *every_env
  key3: value3

test:
  <<: *non_production_env

production:
  <<: *every_env
  key4: value4

Then in your environment.rb you put the following:

MyConfig = ConfigurationManager.new_manager

Which will allow you to access your settings wherever you need them:

MyConfig.inner_hash.key2 #=> value2
MyConfig.key4 #=> value4
etc...

I hope you get the idea…it should make sense. :)

Development of the plugin is on Github, but you can install it from our usual Google Code repository:

script/plugin install http://wonsys.googlecode.com/svn/plugins/configuration_manager/

If you find any bugs, please let us know using our bug tracker.

Still here

Hey everyone! It’s been a long a time since our last post, but in the past few months we’ve been incredibly busy working on a few projects: both for ourselves and for our clients. Of course, we love being busy and don’t complain about it, but we had to put the blog on..

16bugs: new version launch

I’m very proud to announce yesterday we released the all new version of 16bugs. 16bugs was introduced almost two years ago and we felt the need to rewrite it from scratch to include all the valuable feedback you have been sending our way. We released the first part of the upgrade, with a..

Pixménage

We’re finally ready to announce another client project we’ve been working on since the end of Spring: Pixménage. Pixménage allows photographers to manage their digital — or digital-ized, as I prefer them ;) — photos with ease. You can create an online..

Music Milker

As promised yesterday, here we are with another announcement: today, we’re launching a new website: Music Milker. Music Milker is a blog about music where we will post a new song from an up and coming artist everyday. Every week, we will have the artist of the week, with an interview with..

Music Milker: Discover new moosic