I have several variables that I would like to get from all controllers. Therefore, I defined them in my application application_controller.rb:
before_filter :initialize_vars def initialize_vars @siteTitle = "my title" @companyName = "company" end
No problems. I wanted to do something similar with the logo, so I created another method that was called using before_filter.
def logo image_tag("Logo.jpg", :alt => "Logo") end
one instance of the img logo should link to the root of the site, so I called it with:
<%=h link_to logo, root_path %>
but it didnβt work in my layout! When I add my logo method to application_helper.rb, everything works fine. hhmmm.
what / where is a suitable place for all this? I mean only because I was able to do this, it does not do everything right!
Should I define my instance variables (which I consider to be global variables) in the application_controller and the logo method in my helper, how did I do this? I feel that I lack a fundamental understanding of why they need to go to different places. I'm not sure if this is HOW I call the βlogoβ method or where I put it. I will play with the way I call, and how I wrote the logo method, because I feel that both methods should go to application_controller.
thoughts?
Thanks!
source share