From 9a57e7f9bb50ef3d4090d75354c254906d4905b7 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Wed, 7 Oct 2015 12:50:39 +0530 Subject: Follow DRY principle and remove duplication --- actionview/lib/action_view/routing_url_for.rb | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'actionview/lib/action_view/routing_url_for.rb') 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 -- cgit v1.2.3