简体   繁体   English

在rails应用程序的ruby中使用application.html.erb以外的布局?

[英]Using a layout other than application.html.erb in ruby on rails application?

How could I create and use a new template instead of application.html.erb in a RoR application? 如何在RoR应用程序中创建和使用新模板而不是application.html.erb? What are the setting that I need to change to have another template? 有什么设置需要更改才能拥有另一个模板?

Actually, all controllers will search for same-named layouts by default inside /views/layouts folder with fallback to application.html.erb . 实际上,默认情况下,所有控制器都会在/views/layouts文件夹中搜索同名布局,并回退到application.html.erb For example, UsersController will search for users.html.erb . 例如, UsersController将搜索users.html.erb Anyway, to use other layout add next to your controller: 无论如何,要在控制器旁边使用其他布局添加:

class UsersController < ApplicationController
  layout 'custom'
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM