one layout - many templates

Hi , imagine that you have one layout and every point of that is made with another templates. how can i handle this situation. For example in the left column ,displaying list of subcategories depending on category which is displayed at this time in the center of site (<%= yield :layout %> line). it might be develop , making navigations randomly changing like amazon.com

Hi , imagine that you have one layout and every point of that is made with another templates. how can i handle this situation. For example in the left column ,displaying list of subcategories depending on category which is displayed at this time in the center of site (<%= yield :layout %> line). it might be develop , making navigations randomly changing like amazon.com

I typically do it like this:

layouts/application.html.erb:

.... <div id='main-content'>    <%= yield %> </div> ... <div id='left-column'>    <%= yield :left_column %> </div>

Then in my other views I do whatever is simplest to generate content for the left column... perhaps...

<% content_for :left_column do %>    <%= render :partial => 'left_column' %> <% end %>

Where that would pick up a specific left_column partial for that controller. That sort of thing...

-philip

<% content_for :left_column do %>    <%= render :partial => 'left_column' %> <% end %>

where this codes should be? in the layout folder?

if i understand , i must generate 2 files (one is template ,other one is _left_column.html.erb partial templats) , am i right?

<% content_for :left_column do %>   <%= render :partial => 'left_column' %> <% end %>

where this codes should be? in the layout folder?

No... that would go in say /app/views/products/_left_column.html.erb

THen when you're in your products views you could use the above to
load up that left column.

what will be if i display another controller , it will give me undefined method cause left column is depended on product controller ,i want a template working in many controllers

is there any sample code for this navigation, i tried to put variable in application controller , but it didnt work , when i put @var ="abc" in application controller then i wrote <%= @var %> , it displayed nothing.