[Rails] global var?
What's the best way to add a global var (I know it's bad).
I have an Agency model with properties like phone and I need to display on each page agency.phone and agency.address. I moved the footer in a partial so the _footer.rhtml looks like
How to get the @agency visible from everywhere? I thought Application is made for this but don't know howto do it...
You put a before_filter in the app/controllers/application.rb:
(or other code if you want to set the var to something else ;-))
ApplicationController < ActionController::Base
@agency = Agency.find(1)
thanks again Fenrir2, I'll have to add your name to the credits ;)
No problem, but that would be cool :P.