aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-14 13:36:58 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-14 13:36:58 -0300
commit51a52cb836a5aa7139c9563c9db9860d1db60c66 (patch)
treed9d089e755663304b39b85e27f625daa9e6b7799 /actionview/lib
parent307a519d82a5870e4cff26338bb04272fbe7ab50 (diff)
parentb8ad4b54730bf52fbaeb2d172229cc412fd60561 (diff)
downloadrails-51a52cb836a5aa7139c9563c9db9860d1db60c66.tar.gz
rails-51a52cb836a5aa7139c9563c9db9860d1db60c66.tar.bz2
rails-51a52cb836a5aa7139c9563c9db9860d1db60c66.zip
Merge remote-tracking branch 'apotonick/simplify-prefixes'
This is the rebased version of #15026 Closes #15026
Diffstat (limited to 'actionview/lib')
-rw-r--r--actionview/lib/action_view/view_paths.rb37
1 files changed, 22 insertions, 15 deletions
diff --git a/actionview/lib/action_view/view_paths.rb b/actionview/lib/action_view/view_paths.rb
index 6c349feb1d..1fc4c7aa43 100644
--- a/actionview/lib/action_view/view_paths.rb
+++ b/actionview/lib/action_view/view_paths.rb
@@ -14,29 +14,36 @@ module ActionView
:locale, :locale=, :to => :lookup_context
module ClassMethods
- def parent_prefixes
- @parent_prefixes ||= begin
- parent_controller = superclass
- prefixes = []
+ def _prefixes
+ @_prefixes ||= begin
+ deprecated_prefixes = handle_deprecated_parent_prefixes and return deprecated_prefixes
- until parent_controller.abstract?
- prefixes << parent_controller.controller_path
- parent_controller = parent_controller.superclass
- end
-
- prefixes
+ return local_prefixes if superclass.abstract?
+ local_prefixes + superclass._prefixes
end
end
+
+ private
+
+ # Override this method in your controller if you want to change paths prefixes for finding views.
+ # Prefixes defined here will still be added to parents' <tt>::_prefixes</tt>.
+ def local_prefixes
+ [controller_path]
+ end
+
+ def handle_deprecated_parent_prefixes # TODO: remove in 4.3/5.0.
+ return unless respond_to?(:parent_prefixes)
+ ActiveSupport::Deprecation.warn "Overriding ActionController::Base::parent_prefixes is deprecated, override ::local_prefixes or ::_prefixes instead."
+ local_prefixes + parent_prefixes
+ end
end
# The prefixes used in render "foo" shortcuts.
def _prefixes
- @_prefixes ||= begin
- parent_prefixes = self.class.parent_prefixes
- parent_prefixes.dup.unshift(controller_path)
- end
+ self.class._prefixes
end
+
# LookupContext is the object responsible to hold all information required to lookup
# templates, i.e. view paths and details. Check ActionView::LookupContext for more
# information.
@@ -93,4 +100,4 @@ module ActionView
end
end
end
-end
+end \ No newline at end of file