diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-08-02 02:55:01 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-03 22:59:10 +0200 |
commit | befa77fc18ba54c1be89553466312039c1073f02 (patch) | |
tree | cf154b7b05f185120c42614653fef38043c05ca6 | |
parent | e063879daf55f100f316ad55f44a0df6d545693d (diff) | |
download | rails-befa77fc18ba54c1be89553466312039c1073f02.tar.gz rails-befa77fc18ba54c1be89553466312039c1073f02.tar.bz2 rails-befa77fc18ba54c1be89553466312039c1073f02.zip |
Fix generating urls with mounted helpers in view context
There were actually 2 problems with this one:
* script_name was added to options as a string and then it was used
in RouteSet#url_for with usage of <<, which was changing the original
script_name
* the second issue was with _with_routes method. It was called in RoutesProxy
to modify _routes in view_context, but url_helpers in views is just delegating
it to controller, so another _with_routes call is needed there
-rw-r--r-- | actionpack/lib/action_controller/metal/url_for.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 2 | ||||
-rw-r--r-- | actionpack/lib/action_view/helpers/url_helper.rb | 4 |
3 files changed, 5 insertions, 3 deletions
diff --git a/actionpack/lib/action_controller/metal/url_for.rb b/actionpack/lib/action_controller/metal/url_for.rb index e7eb7485c4..1e34f21c77 100644 --- a/actionpack/lib/action_controller/metal/url_for.rb +++ b/actionpack/lib/action_controller/metal/url_for.rb @@ -7,7 +7,7 @@ module ActionController def url_options options = {} if _routes.equal?(env["action_dispatch.routes"]) - options[:script_name] = request.script_name + options[:script_name] = request.script_name.dup end super.merge(options).reverse_merge( diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index c67b0199ce..6e7e133cc5 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -307,7 +307,7 @@ module ActionDispatch routes = self MountedHelpers.class_eval do define_method "_#{name}" do - RoutesProxy.new(routes, (self.respond_to?(:controller) ? controller : self)) + RoutesProxy.new(routes, self) end end diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index b8df2d9a69..f21cffea26 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -29,7 +29,9 @@ module ActionView # def url_options return super unless controller.respond_to?(:url_options) - controller.url_options + controller.send(:_with_routes, _routes) do + controller.url_options + end end # Returns the URL for the set of +options+ provided. This takes the |