I have an application layout in my rails app to give a default header/footer for my entire website. I have 1 controller that I dont want this to apply to (a checkout page), and an entire namespace that needs to have a separate default template (the admin interface, which has 10-15 different contr开发者_如何学Goollers). What is the easiest way to do this?
app/views/layouts/application.html.erb
Will set the default for the entire layout. To override for a specific model, just have
app/views/layouts/mymodel.html.erb
I believe that will work for namespaces also, so long as your layouts directory structure matches your models' directory structure.
http://apidock.com/rails/ActionController/Layout/ClassMethods/layout
Just create new layout file (ie: /app/views/layouts/new_layout.html.erb) and set it in the beginning of the controller:
layout 'new_layout'
精彩评论