Organisation of code in rails app

I was in a similar situation as well, and what Elliott has suggested
will work. However, you have to realize that the initialization of
that @tags variable will happen for every single call made to any
method belonging to any of the controllers. This is because the
controllers inherit from ApplicationController, and that filter is run
everytime before any controller method runs, so you'd effectively be
doing your initialization of stuff not only when your rails
application starts, but also each time a controller's method is

I'm not sure what the best way to avoid having this happen is, but
what I've done is created another class (say 'ClassFoo') containing
the information I want to have initialized once, with this info being
contained in class variables, and accessed through class methods. In
the above init before_filter, I then make a call into some function
'foo' which is a class method of 'ClassFoo', which performs all the
initialization. However since this class is not an actual controller,
it's class variables can be made to be initialized only once (by
having some boolean class variable to check whether I've initialized
yet). So you're still going to end up calling 'foo' on each controller
method invocation, however the initialization can be controlled to
occur only once.

Hopefully that made some sense. I'm not claiming its the nicest way by
any means, but I couldn't find any other way.