Permalink
Browse files

remove AV.prepare and move all helper-related logic into the controll…

…er. this decouples the view since it no longer knows about routes internals.

this is a result of an ongoing discussion at rails#6826.
  • Loading branch information...
apotonick committed Jun 29, 2012
1 parent 809bdf3 commit 1b01ab495968eb38843e21a61d32ef9a44a6d89a
Showing with 13 additions and 19 deletions.
  1. +13 −3 actionpack/lib/abstract_controller/rendering.rb
  2. +0 −16 actionpack/lib/action_view/base.rb
@@ -49,9 +49,19 @@ def process(*) #:nodoc:
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
@@ -166,22 +166,6 @@ def cache_template_loading=(value)
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

0 comments on commit 1b01ab4

Please sign in to comment.