aboutsummaryrefslogtreecommitdiffstats
path: root/actionview
diff options
context:
space:
mode:
authorAbhishek Jain <abhishek.jain@vinsol.com>2015-10-07 12:50:39 +0530
committerAbhishek Jain <abhishek.jain@vinsol.com>2015-10-08 22:33:55 +0530
commit9a57e7f9bb50ef3d4090d75354c254906d4905b7 (patch)
tree657fd5b8b00ff05746510e9cdcf040222afde751 /actionview
parent27c970f00065a4913f5af4bfd352fda382a39060 (diff)
downloadrails-9a57e7f9bb50ef3d4090d75354c254906d4905b7.tar.gz
rails-9a57e7f9bb50ef3d4090d75354c254906d4905b7.tar.bz2
rails-9a57e7f9bb50ef3d4090d75354c254906d4905b7.zip
Follow DRY principle and remove duplication
Diffstat (limited to 'actionview')
-rw-r--r--actionview/lib/action_view/routing_url_for.rb16
1 files changed, 6 insertions, 10 deletions
diff --git a/actionview/lib/action_view/routing_url_for.rb b/actionview/lib/action_view/routing_url_for.rb
index b4cbc80bd5..87e7e9ade7 100644
--- a/actionview/lib/action_view/routing_url_for.rb
+++ b/actionview/lib/action_view/routing_url_for.rb
@@ -84,21 +84,13 @@ 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)
- 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)
@@ -147,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