提交 f3c703a3 编写于 作者: P Piotr Sarnacki

Refactor RoutesProxy to avoid using _with_routes in helpers

上级 434139f8
......@@ -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,6 +22,10 @@ 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)
......@@ -29,9 +33,7 @@ module UrlHelper
#
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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册