From 39de84d96739012d2b2d8fd76976bbd798cd2573 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 22 Sep 2007 17:19:26 +0000 Subject: Fixed that setting the :host option in url_for would automatically turn off :only_path (since :host would otherwise not be shown) (closes #9586) [Bounga] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7542 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- actionpack/lib/action_view/helpers/url_helper.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_view/helpers') diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 01427f8bb8..76963a20b3 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -20,7 +20,7 @@ module ActionView # # ==== Options # * :anchor -- specifies the anchor name to be appended to the path. - # * :only_path -- if true, returns the relative URL (omitting the protocol, host name, and port) (true by default) + # * :only_path -- if true, returns the relative URL (omitting the protocol, host name, and port) (true by default unless :host is specified) # * :trailing_slash -- if true, adds a trailing slash, as in "/archive/2005/". Note that this # is currently not recommended since it breaks caching. # * :host -- overrides the default (current) host if provided @@ -65,7 +65,8 @@ module ActionView def url_for(options = {}) case options when Hash - options = { :only_path => true }.update(options.symbolize_keys) + show_path = options[:host].nil? ? true : false + options = { :only_path => show_path }.update(options.symbolize_keys) escape = options.key?(:escape) ? options.delete(:escape) : true url = @controller.send(:url_for, options) when String -- cgit v1.2.3