2015-10-15 64 views

回答

0

为了延长MarsAtomic的答案,你需要看看layout方法:

#app/controllers/application_controller.rb 
class ApplicationController < ActionController::Base 
    layout false #-> this will not render any layout each time an action inside this controller is invoked 
end 

#app/controllers/application_controller.rb 
class ApplicationController < ActionController::Base 
    def index 
     layout false #-> no layout only for "application#index" 
    end 

    def show 
     render :new, layout: "test" #-> renders "new" action with "test" layout 
    end 
end 
+0

是否有仍然适用该网页上引导的方法吗?因为当我这样做,是的,它不适用布局,但它也忽略了引导。 – bystrik

+1

别担心,它已经排序。 – bystrik

+0

不错 - 你是怎么修好的? –

1

为了说明问题,我们假设您想要在index操作中抑制引导程序导航栏,以获取名为Foo的模型。

在你foos_controller.rb,你会添加以下到index方法:

render :layout => false 

index视图将无application.html.erb内容呈现。

如果您希望包含引导程序导航栏中的application.html.erb aside的某些部分,则必须编辑index.html.erb以包含它们。