替代Rails 3中的prepend / append_view_path?

时间:2011-03-29 22:02:38

标签: ruby-on-rails ruby-on-rails-3

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

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

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

1 个答案:

答案 0 :(得分:4)

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

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