aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/routing_url_for.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionview/lib/action_view/routing_url_for.rb')
-rw-r--r--actionview/lib/action_view/routing_url_for.rb23
1 files changed, 15 insertions, 8 deletions
diff --git a/actionview/lib/action_view/routing_url_for.rb b/actionview/lib/action_view/routing_url_for.rb
index 0371db07dc..45e78d1ad9 100644
--- a/actionview/lib/action_view/routing_url_for.rb
+++ b/actionview/lib/action_view/routing_url_for.rb
@@ -32,7 +32,7 @@ module ActionView
#
# ==== Examples
# <%= url_for(action: 'index') %>
- # # => /blog/
+ # # => /blogs/
#
# <%= url_for(action: 'find', controller: 'books') %>
# # => /books/find
@@ -84,21 +84,24 @@ module ActionView
when Hash
options = options.symbolize_keys
unless options.key?(:only_path)
- if options[:host].nil?
- options[:only_path] = _generate_paths_by_default
- else
- options[:only_path] = false
- end
+ options[:only_path] = only_path?(options[:host])
+ end
+
+ super(options)
+ when ActionController::Parameters
+ unless options.key?(:only_path)
+ options[:only_path] = only_path?(options[:host])
end
super(options)
when :back
_back_url
when Array
+ components = options.dup
if _generate_paths_by_default
- polymorphic_path(options, options.extract_options!)
+ polymorphic_path(components, components.extract_options!)
else
- polymorphic_url(options, options.extract_options!)
+ polymorphic_url(components, components.extract_options!)
end
else
method = _generate_paths_by_default ? :path : :url
@@ -136,5 +139,9 @@ module ActionView
def _generate_paths_by_default
true
end
+
+ def only_path?(host)
+ _generate_paths_by_default unless host
+ end
end
end