[英]Is it possible to not yield from a certain page?
试图创建一个页面,它不会占用layouts / application.html.erb中的所有内容,这可能吗?
The following will display your content unless you are on a specific page: 除非您在特定页面上,否则以下内容将显示您的内容:
yield(:something) unless controller_name == 'mycontroller' and action_name == 'myaction'
The following will output header and includes unless you are on a specific page: 以下将输出标头,并包含标头,除非您在特定页面上:
if controller_name == 'mycontroller' and action_name == 'myaction'
javascript_include_tag :defaults
javascript_include_tag 'anotherscript.js'
yield(:head)
end
In your controller: 在您的控制器中:
def my_action
render :layout => false
end
在控制器中调用render :action => "foo", :layout => false
将完全跳过您的布局。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.