diff options
author | Andrew White <pixeltrix@users.noreply.github.com> | 2015-10-07 22:25:39 +0100 |
---|---|---|
committer | Andrew White <pixeltrix@users.noreply.github.com> | 2015-10-07 22:25:39 +0100 |
commit | fef1064052aeda3701913d3171f17fd4fc84d3f0 (patch) | |
tree | 5fdea0860cdbb8fc383a25e67e66877ad9542abe /actionpack | |
parent | 54f3a18eeceb12c99a7a7463048cd13ee6a51778 (diff) | |
parent | bcfbd8ba2192c82aadef6a1d6ba3e87a603ca4f5 (diff) | |
download | rails-fef1064052aeda3701913d3171f17fd4fc84d3f0.tar.gz rails-fef1064052aeda3701913d3171f17fd4fc84d3f0.tar.bz2 rails-fef1064052aeda3701913d3171f17fd4fc84d3f0.zip |
Merge pull request #21804 from merhard/mounted_engine_route_fix
Mounted engine route fix
Diffstat (limited to 'actionpack')
-rw-r--r-- | actionpack/CHANGELOG.md | 8 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/action_dispatch/routing/route_set.rb | 8 |
3 files changed, 15 insertions, 2 deletions
diff --git a/actionpack/CHANGELOG.md b/actionpack/CHANGELOG.md index a0a12f1b0e..a50b81b439 100644 --- a/actionpack/CHANGELOG.md +++ b/actionpack/CHANGELOG.md @@ -1,3 +1,11 @@ +* Fix regression in mounted engine named routes generation for app deployed to + a subdirectory. `relative_url_root` was prepended to the path twice (e.g. + "/subdir/subdir/engine_path" instead of "/subdir/engine_path") + + Fixes #20920. Fixes #21459. + + *Matthew Erhard* + * ActionDispatch::Response#new no longer applies default headers. If you want default headers applied to the response object, then call `ActionDispatch::Response.create`. This change only impacts people who are 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) diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index e4b8d5993e..339e2b7c4a 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -656,14 +656,18 @@ module ActionDispatch RESERVED_OPTIONS = [:host, :protocol, :port, :subdomain, :domain, :tld_length, :trailing_slash, :anchor, :params, :only_path, :script_name, - :original_script_name] + :original_script_name, :relative_url_root] def optimize_routes_generation? default_url_options.empty? end def find_script_name(options) - options.delete(:script_name) || relative_url_root || '' + options.delete(:script_name) || find_relative_url_root(options) || '' + end + + def find_relative_url_root(options) + options.delete(:relative_url_root) || relative_url_root end def path_for(options, route_name = nil) |