Forum: Ruby on Rails Where to store Application parameters

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
01b3d9e37307865fee8130ca7076acdd?d=identicon&s=25 Tuka Opaleye (tuka)
on 2007-01-02 18:05

I am considering where to place app parameters for a ROR app I am

I need, with very little frquency, to be able to edit the parameters
from the app. i dont want to hard code anything in file.

What would you recomend as a best practise?

Here are the options I consider:

1) The database where a row will have fields for all the app param (with
possible versioning to record changes). Con - a slow db access each time

2) read/write to file: Slow and would like to avoid writing to directory
tree. i.e. giving write permission.

3) Keeping in memory as a global variable - possibly read from db once
and only changes when updated. - A question that comes to mind is would
it be possible to keep an object in a global variable ?

6d3c187a8b3ef53b08e3e7e8572c4fea?d=identicon&s=25 Jeremy McAnally (Guest)
on 2007-01-02 18:15
(Received via mailing list)
The in-memory solution would be the easiest I suppose, but if
volatility is a problem then I wouldn't suggest it.

How about serializing a settings object to the database using YAML?
Keep the object in memory and then drop it to the database when saved.
 Just use the rows to hold revisions of that object.  Of course, with
ActiveRecord, that's could/should just create a model
and do it that way probably.

The best solution is probably to use environment.rb, but since you
don't want to hardcode anything, I think maybe the DB is the way to


On 1/2/07, Tuka Opaleye <> wrote:
> it be possible to keep an object in a global variable ?
> TIA,
> tuka
> --
> Posted via
> >

My free Ruby e-book:

My blogs:
8b22ad683842861ba91f68d5d32954db?d=identicon&s=25 Jason Norris (Guest)
on 2007-01-02 18:45
(Received via mailing list)
Also, if you install memcached and cached_model, then you can use your
parameters as a cached object - it will stay in RAM most of the time and
you'll only have slow DB calls every once in a while. Other than that it
works exactly the same as normal Active Record.
01b3d9e37307865fee8130ca7076acdd?d=identicon&s=25 Tuka Opaleye (tuka)
on 2007-01-03 01:10

Thanks guys, your ideas are helpful

I think i will start off with a database access to the parameters and
later refactor to one ofthe alternate solutions for more performace.

F01c3ff32fee35d911e81c172a005012?d=identicon&s=25 Tom Fakes (Guest)
on 2007-01-03 05:43
(Received via mailing list)
Checkout the Settings and AppConfig plugins at the plugin directory
site.  They probably have all the code you need.
This topic is locked and can not be replied to.