如何渲染模板和布局? [英] How to render a template and layout?
本文介绍了如何渲染模板和布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在控制器方法中,如何渲染模板和布局?
In a controller method, how can you render a template and layout?
像这样:
def new
render :template => 'devise/invitations/new', :layout => 'application_unauthorized2_t2'
end
推荐答案
与大多数 rails 方法一样,render 方法不是一个选项哈希,而是一系列参数,其中 最后一个是一个选项哈希.render 的第一个参数是模板,作为一个字符串.您无需将其包含在选项哈希中.
Instead of just being an options hash, like most rails methods, the render method is a series of arguments, the last of which is an options hash. The first argument to render is the template, as a string. You don't need to include it in the options hash.
就这样做:
def new
render 'devise/invitations/new', :layout => 'application_unauthorized2_t2'
end
这篇关于如何渲染模板和布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文