Permalink
Browse files

Refactor RoutesProxy to avoid using _with_routes in helpers

  • Loading branch information...
1 parent 434139f commit f3c703a32f6c7833705e46b8e14f172330a1c916 @drogus drogus committed Aug 4, 2010
@@ -307,7 +307,7 @@ def define_mounted_helper(name)
routes = self
MountedHelpers.class_eval do
define_method "_#{name}" do
- RoutesProxy.new(routes, self)
+ RoutesProxy.new(routes, self._routes_context)
end
end
@@ -141,6 +141,10 @@ def _with_routes(routes)
ensure
@_routes = old_routes
end
+
+ def _routes_context
+ self
+ end
end
end
end
@@ -22,16 +22,18 @@ module UrlHelper
include ActionDispatch::Routing::UrlFor
include TagHelper
+ def _routes_context
+ controller
+ end
+
# Need to map default url options to controller one.
# def default_url_options(*args) #:nodoc:
# controller.send(:default_url_options, *args)
# end
#
def url_options
return super unless controller.respond_to?(:url_options)
- controller.send(:_with_routes, _routes) do
- controller.url_options
- end
+ controller.url_options
end
# Returns the URL for the set of +options+ provided. This takes the

0 comments on commit f3c703a

Please sign in to comment.