Instance variables in application layout

Praveen Jayarajan wrote:


I have an application layout, and in it there is a sidebar. What i want to do is put things like tags, newly registered users, recent comments, etc in the sidebar.

I am not sure how to do this...

What controller does the application layout access instance variables from? I presume you can use the application controller, but am not quite sure how...


If your site has a global layout it'd be quite normal to have the following lines in application.rb

class ApplicationController

layout 'application' before_filter :set_layout_variables

def set_layout_variables   @stuff = Stuff.find(:all) end


Then all controllers will inherit this before_filter and by default render their output into the layout /app/views/layouts/application.html.erb