gpt4 book ai didi

ruby-on-rails - 如何使特定 View 不继承自 application.html.erb?

转载 作者:太空宇宙 更新时间:2023-11-03 17:21:36 25 4
gpt4 key购买 nike

我有一个具体的观点,即我不想“继承”layouts/application.html.erb 中的代码。它应该怎么做?

一种方法是在 application.html.erb 中包含:

<% except current_page?(page_path) %>
content
<% end %>

但我觉得更像是你应该在特定 View 中指定的东西。这件事的惯例是什么?

最佳答案

对于一个 Action ,你可以尝试:

class TestController < ApplicationController
def method_name
render :layout => 'another_layout'
end
end

对于 Controller 中的所有操作,您可以:

class TestController < ApplicationController
layout 'another_layout'

#action methods here
end

关于ruby-on-rails - 如何使特定 View 不继承自 application.html.erb?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35091052/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com