Permalink
Browse files

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
  • Loading branch information...
1 parent e063879 commit befa77fc18ba54c1be89553466312039c1073f02 @drogus drogus committed Aug 2, 2010
View
2 actionpack/lib/action_controller/metal/url_for.rb
@@ -7,7 +7,7 @@ module UrlFor
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(
View
2 actionpack/lib/action_dispatch/routing/route_set.rb
@@ -307,7 +307,7 @@ def define_mounted_helper(name)
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
View
4 actionpack/lib/action_view/helpers/url_helper.rb
@@ -29,7 +29,9 @@ module UrlHelper
#
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

0 comments on commit befa77f

Please sign in to comment.