This is what I do to have different sidebar per controller:
application_helper.rb
def render_sidebar
if @sidebar_content @sidebar_content
elsif
FileTest.exist?("#{controller.template_root}/#{controller.controller_name}/_sidebar.rhtml")
render :partial => ‘sidebar’
end
end
Then just call render_side inside your layout. You can extend this to
include sidebar per action.
Ah, I see. Seems like a waste, though, doing filesystem lookups on
every page view. I think I’ll just write something that uses a hash
of known possibilities, or look at restructuring my view code. Thanks.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.