It's in my understanding that I 开发者_JS百科can specify a layout for a controller by putting
layout 'mylayout'
in the controller file. I further understand that I can specify certain actions that the layout will be invoked for with :only and :except as such:
    layout 'mylayout', :only => [:index, :new]
or
    layout 'mylayout', :except => [:index, :new]
What I am wondering is, can I put layout 'mylayout' in my application controller and specify that to be rendered for only certain controllers with something like :only_controller and :except_controller, or do I have to specify layout 'mylayout' in every controller I want it to be rendered in?
The reason for this is that I have a few controllers that are in charge of the admin section of my site, and I'd like to have a different layout for them.
Have the admin controllers inherit from an AdminController and create an admin.html.erb layout. That way all the controllers for your admin section will have this layout.
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论