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
What is the "rails" way of doing this?
Thank You for reading,
Memcached - it is a scalable hash/dictionary that is easily shared
between multiple instances.
Use a session.
Learn about Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME)
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.
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.