# How do I create globally available resources?

**URL:** <https://www.ruby-forum.com/t/how-do-i-create-globally-available-resources/133279>\
**Category:** Rails\
**Created:** [March 29, 2008, 6:18pm UTC](https://www.ruby-forum.com/t/how-do-i-create-globally-available-resources/133279 "2008-03-29T18:18:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![M\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c67d28/32.png) [@M\_P](https://www.ruby-forum.com/u/M_P)\
**Post date:** [March 29, 2008, 6:18pm UTC](https://www.ruby-forum.com/t/how-do-i-create-globally-available-resources/133279/1 "2008-03-29T18:18:05Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![M\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c67d28/32.png) [@M\_P](https://www.ruby-forum.com/u/M_P)\
**Post date:** [March 29, 2008, 8:29pm UTC](https://www.ruby-forum.com/t/how-do-i-create-globally-available-resources/133279/2 "2008-03-29T20:29:01Z")

</div>

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

Marc  
[Cloudcache.net](http://Cloudcache.net)

Sent from my iPhone

---

<div class="post-metadata">

**Author:** ![M\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c67d28/32.png) [@M\_P](https://www.ruby-forum.com/u/M_P)\
**Post date:** [March 31, 2008, 6:48am UTC](https://www.ruby-forum.com/t/how-do-i-create-globally-available-resources/133279/3 "2008-03-31T06:48:51Z")

</div>

Use a session.

Julian.

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

---

<div class="post-metadata">

**Author:** ![M\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/c67d28/32.png) [@M\_P](https://www.ruby-forum.com/u/M_P)\
**Post date:** [March 31, 2008, 7:47am UTC](https://www.ruby-forum.com/t/how-do-i-create-globally-available-resources/133279/4 "2008-03-31T07:47:34Z")

</div>

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.

😉

-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.
