gpt4 book ai didi

ruby-on-rails - 更改 Rails 中的默认 View 路径?

转载 作者:数据小太阳 更新时间:2023-10-29 07:31:01 25 4
gpt4 key购买 nike

我希望能够动态更改 View 文件夹。目的是能够根据要求完全改变网页设计。我在想这样的事情:

 Class PagesController

default_views_path(current_theme_path)

def show
Blablah...
end

end

假设这样的目录架构:

 -apps
--views
---theme 1/show.html.erb
---theme 2/show.html.erb
---theme 3/show.html.erb

我在网上搜索并找到了 preprend_view_path。 (:deprecated) 你认为这是一个好主意吗?有什么反馈吗?

编辑

事实上,我想简化这个:

 Class PagesController

def show
render "#{current_theme}/show"
end

def edit
render "#{current_theme}/edit"
end

def list
render "#{current_theme}/list"
end

def index
render "#{current_theme}/index"
end

end

任何解决方案?

最佳答案

你可以使用 append_view_path .事实上,这个 append_view_path 页面上有一条评论,有人用它来制作主题。

关于ruby-on-rails - 更改 Rails 中的默认 View 路径?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6178349/

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