On 10/13/06, Jon W. [email protected] wrote:
<%= @content_for_sidebar %>
<% end %>
It is better to use <%= yield ‘sidebar’ %> instead.of <%=
In your individual views:
<% content_for ‘sidebar’ do -%>
Put some content here!
<% end %>
Note that you don’t need the if statement in the layout if you always
fill out the content_for_sidebar but in my views I often leave some
content sections empty.
If you just need to prepare data for your sidebar, you can use
of common partial + before_filter in e.g. ApplicationController to
data for partial.
But if your sidebar is dependant on particular section, I would suggest
using nested_layouts plugin (http://nested-layouts.rubyforge.org) and
“content_for” helper (described above). So for every “section” (a group
pages with the same sidebar) you could use the same inner layout that
prepare sidebar content and wrap page content in outer (your main)
Take a look at nested_layouts plugin documentation - it has example of
what (I guess) you need.