From 1b01ab495968eb38843e21a61d32ef9a44a6d89a Mon Sep 17 00:00:00 2001 From: Nick Sutterer Date: Fri, 29 Jun 2012 11:33:37 +0200 Subject: remove AV.prepare and move all helper-related logic into the controller. this decouples the view since it no longer knows about routes internals. this is a result of an ongoing discussion at https://github.com/rails/rails/pull/6826. --- actionpack/lib/abstract_controller/rendering.rb | 16 +++++++++++++--- actionpack/lib/action_view/base.rb | 16 ---------------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/actionpack/lib/abstract_controller/rendering.rb b/actionpack/lib/abstract_controller/rendering.rb index 7d73c6af8d..3da2834af0 100644 --- a/actionpack/lib/abstract_controller/rendering.rb +++ b/actionpack/lib/abstract_controller/rendering.rb @@ -49,9 +49,19 @@ module AbstractController module ClassMethods def view_context_class @view_context_class ||= begin - routes = _routes if respond_to?(:_routes) - helpers = _helpers if respond_to?(:_helpers) - ActionView::Base.prepare(routes, helpers) + routes = respond_to?(:_routes) && _routes + helpers = respond_to?(:_helpers) && _helpers + + Class.new(ActionView::Base) do + if routes + include routes.url_helpers + include routes.mounted_helpers + end + + if helpers + include helpers + end + end end end end diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index f98648d930..4152f40c2e 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -166,22 +166,6 @@ module ActionView #:nodoc: def xss_safe? #:nodoc: true end - - # This method receives routes and helpers from the controller - # and return a subclass ready to be used as view context. - def prepare(routes, helpers) #:nodoc: - Class.new(self) do - if routes - include routes.url_helpers - include routes.mounted_helpers - end - - if helpers - include helpers - self.helpers = helpers - end - end - end end attr_accessor :view_renderer -- cgit v1.2.3 From 67dd94a77492faa0ab40d4596a12a70a96858cf4 Mon Sep 17 00:00:00 2001 From: Nick Sutterer Date: Fri, 29 Jun 2012 13:02:44 +0200 Subject: removing the AV::Base.helpers class attribute as it is not needed. --- actionpack/lib/action_view/base.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/actionpack/lib/action_view/base.rb b/actionpack/lib/action_view/base.rb index 4152f40c2e..7bfbc1f0aa 100644 --- a/actionpack/lib/action_view/base.rb +++ b/actionpack/lib/action_view/base.rb @@ -148,7 +148,6 @@ module ActionView #:nodoc: cattr_accessor :prefix_partial_path_with_controller_namespace @@prefix_partial_path_with_controller_namespace = true - class_attribute :helpers class_attribute :_routes class_attribute :logger -- cgit v1.2.3