diff options
author | Andrew White <andrew.white@unboxed.co> | 2017-03-17 21:30:29 +0000 |
---|---|---|
committer | Andrew White <andrew.white@unboxed.co> | 2017-03-17 21:30:29 +0000 |
commit | fd16e1a92feed73df70e140880cc17b6e482c846 (patch) | |
tree | 2e6282c4ba42aab31f18b05f616b7f8e9268cb5e /actionpack/lib | |
parent | bac40b9cc8bae5a88743dba01bdee24ef8a2d579 (diff) | |
download | rails-fd16e1a92feed73df70e140880cc17b6e482c846.tar.gz rails-fd16e1a92feed73df70e140880cc17b6e482c846.tar.bz2 rails-fd16e1a92feed73df70e140880cc17b6e482c846.zip |
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`.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/url_for.rb | 4 |
2 files changed, 9 insertions, 1 deletions
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 @@ module ActionDispatch @_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 @@ module ActionDispatch 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{(?<!/)/(?!/)}).last diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb index d199bece96..4a23e1c8b6 100644 --- a/actionpack/lib/action_dispatch/routing/url_for.rb +++ b/actionpack/lib/action_dispatch/routing/url_for.rb @@ -164,6 +164,10 @@ module ActionDispatch # implicitly used by +url_for+ can always be overwritten like shown on the # last +url_for+ calls. def url_for(options = nil) + full_url_for(options) + end + + def full_url_for(options = nil) # :nodoc: case options when nil _routes.url_for(url_options.symbolize_keys) |