[英]How to remove application layout from a particualar Ruby on Rails page?
How can I remove the layout application.html.erb from rendering on a particular page.如何从特定页面上的呈现中删除布局 application.html.erb。 It is now visible on all pages in my application.它现在在我的应用程序的所有页面上都可见。
You can override default rendering at the controller level.您可以在 controller 级别覆盖默认渲染。
class Admin::HomeController < Admin::BaseController
layout "admin"
You can also override rendering of layouts at a controller action level:您还可以在 controller 操作级别覆盖布局的呈现:
def show
render :layout => "layout_for_show_only"
end
And, if you are really desperate, you can override layouts in the view:而且,如果你真的很绝望,你可以覆盖视图中的布局:
<%= render "print_view", :layout => "print" %>
See the excellent rails guide on the subject: layouts and rendering in Rails请参阅有关该主题的优秀 Rails 指南: Rails 中的布局和渲染
ian.伊恩
You can simply add to the controller:您可以简单地添加到 controller:
layout false, only: [:show, :edit]
which means, that application layout won't be rendered for the show and edit pages这意味着,将不会为显示和编辑页面呈现该应用程序布局
Here is an answer.这是一个答案。
You can set: format.js {render:layout=>false}你可以设置:format.js {render:layout=>false}
jQuery + Ajax + Haml. jQuery + Ajax + 哈姆尔。 js.erb files not firing js.erb 文件未触发
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.