I'm currently developing a new site where I need different column styles for the content, for example some pages need a one-column style and some need a two-column style with a sidebar.

Pratik Naik has written a great post about nested layouts and it is a very good solution for my problem.

I found out that the technique he used was working with Rails 3.0 but not with Rails 3.1 and Rails 3.2 so here is an updated version for the helper method he created:

# app/helpers/application_helper.rb

def parent_layout(layout)
  @view_flow.set(:layout,output_buffer)
  self.output_buffer = render(file: "layouts/#{layout}")
end  

Now you can just create your sub layouts and add the helper method at the bottom of them:

<!-- app/layouts/one_column.html.erb -->

<div class="one-whole">
  <%= yield %>
</div>

<%= parent_layout('application') %>
<!-- app/layouts/two_column.html.erb -->

<div class="one-half">
  <%= yield %>
</div>
<div class="one-half">
  <%= render "layouts/sidebar" %>
</div>

<%= parent_layout('application') %>

And those will be rendered like every normal view inside the application layout.

<!-- app/layouts/application.html.erb -->

<html>
  <head><title>My Awesome Application</title></head>
  <body>
    <%= yield %>
  </body>
</html>