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

标签 ruby-on-rails ruby ruby-on-rails-3 view themes

我希望能够动态更改 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/

相关文章:

mysql - 呸!我在 ruby​​ 1.9.2 的 Rails 中不断收到此编码错误

ruby-on-rails - 如何使用 rspec 测试带有嵌套路由的 Controller

Ruby 打印格式之间的差异

ruby-on-rails-3 - Rails 引擎中的观察者

ruby - 如何在 Ruby 上使用 Time.strftime 打印土耳其语日/月名称?

mysql - ln :/usr/lib/libmysqlclient. 18.dylib:文件存在

html - 如何添加参数删除链接?

ruby-on-rails - Rails 委托(delegate)更新调用

ruby-on-rails - 视频无法在我的本地主机中使用 Rails 应用程序使用 FFmpeg 进行转码

ruby-on-rails - 设计对基于 Rails 的 Web 服务有意义吗?