I'm a RoR noob so excuse me if this is an obvious question. I've
looked in all my RoR books (I have 5) and tried to find the answer in
the newsgroups but to no avail.
I have an application layout which defines the layout of the site
which has a left and right column and a content column in the middle
(3 col layout).
The left/right column contents can change depending on the current
action, so for example for my login form I do not want anything
displayed in the left but I do for the right. Once logged in I want
something in both columns, the content changes as the user navigates
the site.
My thoughts where to use partials so that the view is responsible for
what gets displayed in these columns. I would have something like this
in the application layout:
I suspect you may want to use different layouts depending on the
circumstance. You may also me interested in the nested layouts
plugin(http://agilewebdevelopment.com/plugins/nested_layouts), I've
found it quite useful for these types of things.
Thanks everyone for your suggestions, I've taken Michael's approach as
I think it will best suit my needs. An added bonus is that I will be
able to share partials in those cases where the same content is
displayed in the left/right columns.
I'm sure this is known, but just to take Michael's example one simple
step further you could add an if statement to only render if the
@right_partial varible has been set.
<div id="right>
<% if @right_partial %>
<%= render :partial => @right_partial %>
<% else %>
<!-- do other stuff -->
<% end %>
</div>