How do I create globally available resources?

Hello,

I want to initialize a giant hash on application startup, and have a controller interact with that hash WITHOUT having to rebuild the hash for every single request. Generating the hash will be a bit time consuming, so I want it built and immutable as soon as I launch the server.

What is the "rails" way of doing this?

Thank You for reading,

- M

Memcached - it is a scalable hash/dictionary that is easily shared
between multiple instances.

Marc Cloudcache.net

Use a session.

Julian.

Learn about Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME) http://sensei.zenunit.com/

Create an initializer. Rails will load any file you dump in RAILS_ROOT/ config/initializers/ when the server starts. That, I believe, would be the most "rails way"-ish way.

:wink:

-Danimal

P.S. Back in the early Rails days, I used to drop a lot of initialization stuff at the end of environments.rb, i.e. custom date displays, reference values, global constants, etc. Now I put 'em in an initializer... just better organized, IMHO.