本文介绍了如何从 ruby on rails 中的某些页面中删除页眉和页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 Rails 项目中工作.我创建了页眉和页脚并添加到 layouts/application.html.erb 文件中的所有页面.现在我想从某些页面中删除它.我该怎么做?
I am working in rails project. I created a header and footer and added to all pages in layouts/application.html.erb file. Now I want to remove it from some pages. how can I do that?
推荐答案
控制器支持 :only
和 :except
布局选项,请参阅 本指南.
Controllers support :only
and :except
options for layouts, see the Conditional layouts section in this guide.
因此您可以在控制器中执行以下操作:
So you can do the following in your controller:
class SomeController < ApplicationController
layout 'application', :except => [:some_action, :some_other_action]
...
这篇关于如何从 ruby on rails 中的某些页面中删除页眉和页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!