I have a nice layout for my app, but for some actions I want to use a shared sub layout. Anyone have ideas what the best practice would be? I have a method that works, but I am not sure if it is the 'rails way' of doing things, anyone care to critique it? I have tried the following...
1) making my action template call render :partial, :collection, :layout. The good new here is that it wraps the layout around the whole collection (not around each item in the collection) and doesn't blow away my main layout. The bad news is the sub-layout and collection are repeated as many times as there are items in the collection. This seems like a rails bug. The layout should be applied once around the whole collection, or once for each item in the collection, not both. 2) applying a layout to the render :action in the controller. This blows away my main layout. This is because i am rendering a template, not a partial, right? 3) using content_for to define a sub-layout. this works, but I feel like there should be an easier way. i am also not sure yet what would happen when i don't want a sub-layout. I guess I could make a _no_sub_layout.html.erb that just yields, or put the content all inside of the content_for block...I have a few other ideas too. One possible benefit is that I think you could keep nesting sub-layouts pretty easily if you wanted. Here is a simplified version of this solution. layout.html.erb <html> <head>head stuff</head> <body> some stuff <%= yield :sublayout %> some stuff </body> </html> index.html.erb <% content_for :sublayout do -%> <%= render :partial =>"sublayout" %> <% end -%> <% for item in @collection do -%> <%= render :partial => "item" -%> <% end -%> _sublayout.html.erb some stuff <%= yield %> some stuff _item.html.erb <%= h item.name %> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

