I’ve been discovering Ruby on Rails during the last 3 months and I’m fascinated. But several things I don’t know which is the best way to do them. Now I’m stack with the initialization of some variables. All the application is running over ajax, so all the instance variables should be initialize only once.
I’ve tried writting a method ‘initialize’ in the applicationController which is run just once, but the problem is that I’m accesing the request object which is not initialized yet.
I’ve tried a before_filter in the applicationController but it is run every request I do, even if it is an ajax request.
Does anyone know how to initialize an instance variable with a value from the request object? Yes, probably a newbie question.
I’m using Ruby 1.8.7 and Rails 3.
Thanks in advance
I assume, you would want to do the initialization part when you land on a page and skip it for all ajax requests from the same page.