Dynamic Configuration Setting

I would like to have a global configuration setting (an interest rate)
that’s settable by the administrator, but would be used in calculations
throughout the app. I’m OK with setting up a single-field, single-value
database table, and an A/R model.

However, is there a pattern for ensuring that there is always one and
only one record in the table?

Thanks,
Cliffe

On Jan 3, 2007, at 12:42 PM, cliffeh wrote:

I would like to have a global configuration setting (an interest rate)
that’s settable by the administrator, but would be used in
calculations
throughout the app. I’m OK with setting up a single-field, single-
value
database table, and an A/R model.

However, is there a pattern for ensuring that there is always one and
only one record in the table?

I don’t like people to touch the database. The pattern we follow is.

There is a config/application.yml.example in svn with those kind of
external configuration parameters which are specific for this
application. The install process says you copy that file to config/
application.yml and change the defaults from the example.

Then in config/environemnt.rb we load it in a global hash:

Load application configuration constants

require ‘yaml’
APPLICATION_CONFIG = YAML::load(File.open(File.join(RAILS_ROOT,
‘config’, ‘application.yml’)))