[英]Ruby on Rails: Rendering a Page without the Application Layout
In my Rails application, I'm trying to define a custom mime type that renders plain html without the site navigation or any formatting (css, etc). 在我的Rails应用程序中,我正在尝试定义一个自定义mime类型,它在没有网站导航或任何格式(css等)的情况下呈现纯HTML。 An answer to an older question that I read described how to do this by turning off the layouts entirely for the current request, but I want my rendered page to include nested layouts , just not the main application layout.
我读到的旧问题的答案描述了如何通过完全关闭当前请求的布局来完成此操作,但我希望我的渲染页面包含嵌套布局 ,而不是主应用程序布局。 How do I do this?
我该怎么做呢?
Try layout nil
for no layout 尝试
layout nil
没有布局
layout 'name' for render your layout.
or you can use 或者你可以使用
render :layout => layout_name
you can render any layout you wish, as in 你可以渲染你想要的任何布局,如
render :layout => "special_nested_super_duper_layout" render:layout =>“special_nested_super_duper_layout”
ensure that the layout is located in app/views/layouts and you are good to go 确保布局位于app / views / layouts中,您就可以了
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.