在 Rails 3 中替代 prepend/append_view_path? [英] Alternative to prepend/append_view_path in Rails 3?

查看:36
本文介绍了在 Rails 3 中替代 prepend/append_view_path?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试向 Rails 查找视图的路径添加另一个目录,我在 ActionController::Base.prepend_view_path 和 ActionController::Base.append_view_path 方法中找到了一个可行的解决方案,但它们都被标记在 Rails 3 中已弃用.我可以使用替代方法吗?

I'm trying to add another directory to the paths that Rails looks in to find views, and I found a working solution in the methods ActionController::Base.prepend_view_path and ActionController::Base.append_view_path, but they are both marked as deprecated in Rails 3. Is there an alternative that I can use?

http://apidock.com/rails/ActionController/Base/prepend_view_path

http://apidock.com/rails/ActionController/Base/append_view_path

推荐答案

ActionController::Base.append/prepend_view_paths 已被弃用,因为它们被提取到 AbstractController 中> 模块.如果您从控制器调用这些方法,将调用 AbstractController 方法,而不是已弃用的 ActionController 方法.

The ActionController::Base.append/prepend_view_paths were deprecated, as they were extracted out into the AbstractController module. If you call those methods from your controller, the AbstractController methods would be called, not the deprecated ActionController one.

https://github.com/rails/rails/blob/master/actionpack/lib/abstract_controller/view_paths.rb#L25

这篇关于在 Rails 3 中替代 prepend/append_view_path?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆