Reputation: 4268
I want to all my views from different paths to use the 'layouts/application.html.erb', except a view that has a specific structure. Is that possible without forcing to create a layout for this view and each one for others?
The 'index.html.erb' couldn`t use the layout 'application.html.erb' in my case.
Upvotes: 2
Views: 162
Reputation: 64363
You can override the default layout by passing an explicit layout name in the render
call.
class FoosController < ApplicationController
def index
# call below uses layouts\new_layout.html.erb as the layout
render :layout => 'new_layout'
# if you want to render without a layout
# render :layout => false
end
end
Upvotes: 3
Reputation: 15955
This is easy. If you want to use a different layout for the entire controller, just put the following at the top of that controller:
class ItemsController < ApplicationController
layout "inventory"
#...
end
Upvotes: 0