Rails Nestable Layouts
Dead simple nested layouts support for Rails. Does not monkey patch anything. Can nest as many layouts as desired.
Install
gem 'rails_nestable_layouts'
Usage
Your Controller
# main layout, this line is not necessary. Note nested_layouts does not override the main layout.
layout :application
# accepts the same options as before_action/before_filter
nested_layouts 'layouts/secondary_layout', 'posts/layout', except: [:index]
Main Layout
<html>
<head></head>
<body>
<h1>My Main Layout</h1>
<!-- this will call the first nested layout , will fallback to normal functionality if no nested layouts. -->
<%= yield_nested %>
</body>
<footer></footer>
</html>
Nested Layout(s)
<h2>My Nested Layout</h2>
<%= yield_nested %> # this will call the next nested layout or the requested template if no more nested layouts.
Credits
Created by Weston Ganger - @westonganger