absolute urls in url_for vs. link_to

In both url_for and link_to, the :only_path param can be used to determine whether the link url used is complete with hostname and path, or just has the path (a kind of relative url).

However, in url_for it defaults to false (urls with hostnames), and in link_to it defaults to true ( urls without hostnames, just paths).

Is there any reason for this discrepency? To me, it violates the principle of least surprise.

Is there any way for me to make Rails default to false for link_to also? I have a case where the urls without hostnames are messing something up, and I really don't want to have to go in and add :only_path to every single call to link_to. I really want to be able to change the default behavior globally. Anyone know if there's a good way to do that?

Something like this (untested, but this is pretty close):

module ActionView    module Helpers      module UrlHelper

       alias_method :link_to_orig :link_to

       def link_to(name, options = {}, html_options = nil, *parameters_for_method_reference)          link_to(name, {:only_path => false}.merge(options), html_options, paramaters_for_method_reference)        end

     end    end end

In both url_for and link_to, the :only_path param can be used to determine whether the link url used is complete with hostname and path, or just has the path (a kind of relative url).

However, in url_for it defaults to false (urls with hostnames), and in link_to it defaults to true ( urls without hostnames, just paths).

Is there any reason for this discrepency? To me, it violates the principle of least surprise.

Is there any way for me to make Rails default to false for link_to also? I have a case where the urls without hostnames are messing something up, and I really don't want to have to go in and add :only_path to every single call to link_to. I really want to be able to change the default behavior globally. Anyone know if there's a good way to do that?

Something like this (untested, but this is pretty close):

module ActionView   module Helpers     module UrlHelper

      alias_method :link_to_orig :link_to

      def link_to(name, options = {}, html_options = nil, *parameters_for_method_reference)         link_to(name, {:only_path => false}.merge(options), html_options, paramaters_for_method_reference)

Bah! the above "link_to" should be "link_to_orig". Heh.