render layout inside other layout - DRY, Rails

Posted by chetan
on Saturday, October 27
put this code block inside your application_helper.rb

  def inside_layout(layout, &block)    
     layout = layout.include?('/') ? layout : "layouts/#{layout}"    
     @template.instance_variable_set("@content_for_layout", capture(&block))    
     concat(@template.render(:file => layout, :user_full_path => true), block.binding)    
   end
Now, use this method in layout, which you want to render in suppose 'application' layout

  <% inside_layout 'application' do %>
    your code
  <% end %>