开发者

How can I use an application layout in rails for all controllers except a few?

开发者 https://www.devze.com 2022-12-24 05:02 出处:网络
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

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'
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号