From fd16e1a92feed73df70e140880cc17b6e482c846 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Fri, 17 Mar 2017 21:30:29 +0000 Subject: [PATCH] Always use original url_for when generating direct routes Action View overrides `url_for` in the view context to render paths by default when using `url_for` and this means that direct route helpers don't get the full url when called with the url suffix. To fix this always call the original `url_for`. --- .../lib/action_dispatch/routing/route_set.rb | 6 ++- .../lib/action_dispatch/routing/url_for.rb | 4 ++ .../activerecord/polymorphic_routes_test.rb | 46 +++++++++++++++++++ 3 files changed, 55 insertions(+), 1 deletion(-) diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 8a9a48938b..7034eff36d 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -509,6 +509,10 @@ def url_for(options) @_proxy.url_for(options) end + def full_url_for(options) + @_proxy.full_url_for(options) + end + def route_for(name, *args) @_proxy.route_for(name, *args) end @@ -619,7 +623,7 @@ def initialize(name, defaults, &block) def call(t, args, only_path = false) options = args.extract_options! - url = t.url_for(eval_block(t, args, options)) + url = t.full_url_for(eval_block(t, args, options)) if only_path "/" + url.partition(%r{(?