diff options
author | Matthew Erhard <merhard@gmail.com> | 2015-09-28 18:00:01 -0400 |
---|---|---|
committer | Matthew Erhard <merhard@gmail.com> | 2015-10-07 12:45:01 -0400 |
commit | bcfbd8ba2192c82aadef6a1d6ba3e87a603ca4f5 (patch) | |
tree | 33c0bece3e8f2d590086f12b0ff066e1efa9999d /actionpack/lib/action_dispatch/routing/mapper.rb | |
parent | e70ec9e91cb63fd63cfc0a285e5d2268a0297e46 (diff) | |
download | rails-bcfbd8ba2192c82aadef6a1d6ba3e87a603ca4f5.tar.gz rails-bcfbd8ba2192c82aadef6a1d6ba3e87a603ca4f5.tar.bz2 rails-bcfbd8ba2192c82aadef6a1d6ba3e87a603ca4f5.zip |
Fix mounted engine named routes regression
When generating the url for a mounted engine through its proxy, the path should be the sum of three parts:
1. Any `SCRIPT_NAME` request header or the value of `ActionDispatch::Routing::RouteSet#relative_url_root`.
2. A prefix (the engine's mounted path).
3. The path of the named route inside the engine.
Since commit https://github.com/rails/rails/commit/44ff0313c121f528a68b3bd21d6c7a96f313e3d3, this has been broken. Step 2 has been changed to:
2. A prefix (the value of `ActionDispatch::Routing::RouteSet#relative_url_root` + the engine's mounted path).
The value of `ActionDispatch::Routing::RouteSet#relative_url_root` is taken into account in step 1 of the route generation and should be ignored when generating the mounted engine's prefix in step 2.
This commit fixes the regression by having `ActionDispatch::Routing::RouteSet#url_for` check `options[:relative_url_root]` before falling back to `ActionDispatch::Routing::RouteSet#relative_url_root`. The prefix generating code then sets `options[:relative_url_root]` to an empty string. This empty string is used instead of `ActionDispatch::Routing::RouteSet#relative_url_root` and avoids the duplicate `relative_url_root` value in the final result.
This resolves #20920 and resolves #21459
Diffstat (limited to 'actionpack/lib/action_dispatch/routing/mapper.rb')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index cfd50f616d..2f1c2afb91 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -665,6 +665,7 @@ module ActionDispatch super(options) else prefix_options = options.slice(*_route.segment_keys) + prefix_options[:relative_url_root] = ''.freeze # we must actually delete prefix segment keys to avoid passing them to next url_for _route.segment_keys.each { |k| options.delete(k) } _routes.url_helpers.send("#{name}_path", prefix_options) |