Hi JSJ - yes no problem, glad to help and it’s good to find out if I
have it right myself
When you call render for a partial in a controller’s
action, does the controller still automatically call its own render?
When you have a layout (mine is in application.rb), each section (i.e.
for header, body, sidebar, footer, etc, can contain render instructions
the content to go in that specific area.
For example, my sidebar has
render :partial => ‘shared/authenticate’
self << content_for_sidebar rescue nil
The first of these renders my authentication partial, and the second
me to specify (optionally, hence the “rescue nil”) content to display in
the sidebar below it.
The authentication partial is common to any controller using this
layout. The content_for_sidebar is specific to the controller’s action
that is being displayed.
Remember the event that causes a page to be displayed in a browser is
the submission of a specific URL requesting a specific controller
will cause the action my_action within my_controller to be executed. If
my_controller contains a “layout” statement then that specific layout
be used, or if “application.rb” exists then that will be used.
The layout can render as many things as it likes, but they will either
shared or relative to my_controller’s my_action. The latter are defined
in the view file for my_controller/my_action.rhtml.
The view file normally contains a default view which is rendered using
self << content_for_layout
However you can also add additional views to the named file by doing
<% content_for(:sidebar) do %>
render this in the sidebar with "self << content_for_sidebar"
<% end %>
I place these specific blocks at the end of the view file, after all of
the code for the “default” view.
These are all the techniques I use and, hopefully, I’m using them right!
a call to render the view for the action is done
automatically on exit. So instead of getting the information I’m
looking for at the top, I’ll get it at the bottom of the page
I think that, by using render or content_for in your layout where YOU
want the layout to appear means you can get your page design to work
however you want.
What I really want to happen is to have the controller’s action render
the information for the object it is responsible for, then each of the
dependent objects in turn. My understanding of the “automatic” render
I haven’t extensively played with views that have multiple models yet,
it is possible and I believe the “depot” example in AWDWR does this when
displaying the cart. I am pretty sure you’ll be able to do what you
Hope this is useful.