An elegant way to nest Rails layouts.
# devise.html.erb
<%= extends :application do %>
<div class="devise-container">
<%= yield %>
</div>
<% end %>
# Add this to your application_helper.rb | |
# From https://github.com/rwz/nestive/blob/master/lib/nestive/layout_helper.rb | |
def extends(layout, &block) | |
# Make sure it's a string | |
layout = layout.to_s | |
# If there's no directory component, presume a plain layout name | |
layout = "layouts/#{layout}" unless layout.include?('/') | |
# Capture the content to be placed inside the extended layout | |
@view_flow.get(:layout).replace capture(&block) | |
render file: layout | |
end |