Need help making a "system wide" config object available

I need to make a config object (a static, unchanging object created
preferably at the application level) available to not only certain
models but other housekeeping objects as well.

I have a config object that is created once and remains in that state
for its entire life so I want to be able to access this object
everywhere where I need it as it is quite large and recreating it more
than once in the same process would be wasteful.

So far I am instantiating it in application.rb but is this the right
place?

How can I refer to the main application object from within a model?
What is the best way of getting at this object?

Thanks.

I do something similar to the following:

config/config.rb:
module Config
CONFIG = {
:config_value_1 => “some string”,
:config_object_1 => SomeObject.new
}
end

then in your environment.rb just:
require ‘config’

Then in your code you could:
include Config

then CONFIG[:config_value_1] where you need the config values in your
code.

However, there is no concept of a ‘shared’ config across all your
mongrel processes for example, each process would have it’s own copy
of the config. I suppose you could try something using memcached or
similar to share things across procs.

On Feb 2, 1:53 pm, Chad T. [email protected]

Thanks Alex, I only need for a single process where the config is reused
in many places - I wanted to avoid loading it over and over in the same
page hit. So what you have suggested looks good and I’ll have a go.