1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Refactor RoutesProxy to avoid using _with_routes in helpers

This commit is contained in:
Piotr Sarnacki 2010-08-04 16:20:56 +02:00
parent 434139f89f
commit f3c703a32f
3 changed files with 10 additions and 4 deletions

View file

@ -307,7 +307,7 @@ module ActionDispatch
routes = self
MountedHelpers.class_eval do
define_method "_#{name}" do
RoutesProxy.new(routes, self)
RoutesProxy.new(routes, self._routes_context)
end
end

View file

@ -141,6 +141,10 @@ module ActionDispatch
ensure
@_routes = old_routes
end
def _routes_context
self
end
end
end
end

View file

@ -22,6 +22,10 @@ module ActionView
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 ActionView
#
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