diff options
author | Ryuta Kamizono <kamipo@gmail.com> | 2018-10-08 17:52:39 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-08 17:52:39 +0900 |
commit | d4127a014c110faa9c4611244f01f4320616a49b (patch) | |
tree | 9e09409823eaaa91085a4b97e8e7995fcecb73ec /actionview/lib | |
parent | 5dbf5c660ce4ad1f989f2d05032664c7ee26488c (diff) | |
parent | b48c2ade09e9c43d6f7acee02d074a9d54323a70 (diff) | |
download | rails-d4127a014c110faa9c4611244f01f4320616a49b.tar.gz rails-d4127a014c110faa9c4611244f01f4320616a49b.tar.bz2 rails-d4127a014c110faa9c4611244f01f4320616a49b.zip |
Merge pull request #33324 from Jcambass/fix-only-path-option-in-url-for-with-arrays
respect only_path option when an array is passed into url_for
Diffstat (limited to 'actionview/lib')
-rw-r--r-- | actionview/lib/action_view/routing_url_for.rb | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/actionview/lib/action_view/routing_url_for.rb b/actionview/lib/action_view/routing_url_for.rb index fd563f34a9..f8ea3aa770 100644 --- a/actionview/lib/action_view/routing_url_for.rb +++ b/actionview/lib/action_view/routing_url_for.rb @@ -84,25 +84,24 @@ module ActionView super(only_path: _generate_paths_by_default) when Hash options = options.symbolize_keys - unless options.key?(:only_path) - options[:only_path] = only_path?(options[:host]) - end + ensure_only_path_option(options) super(options) when ActionController::Parameters - unless options.key?(:only_path) - options[:only_path] = only_path?(options[:host]) - end + ensure_only_path_option(options) super(options) when :back _back_url when Array components = options.dup - if _generate_paths_by_default - polymorphic_path(components, components.extract_options!) + options = components.extract_options! + ensure_only_path_option(options) + + if options[:only_path] + polymorphic_path(components, options) else - polymorphic_url(components, components.extract_options!) + polymorphic_url(components, options) end else method = _generate_paths_by_default ? :path : :url @@ -138,8 +137,10 @@ module ActionView true end - def only_path?(host) - _generate_paths_by_default unless host + def ensure_only_path_option(options) + unless options.key?(:only_path) + options[:only_path] = _generate_paths_by_default unless options[:host] + end end end end |