Forum: Ruby on Rails Absolute URLs

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Kevin McCarthy (Guest)
on 2007-07-11 07:02
(Received via mailing list)
Hey, is there a way I can get link_to to spit out absolute URLs,
rather than relative URLs?  I would like to do this for SEO purposes.
Is there something that I have to subclass to get this to go, or is
there a better hack out there to do this.

Thanks!

Kevin
Alex W. (Guest)
on 2007-07-11 07:47
Kevin McCarthy wrote:
> Hey, is there a way I can get link_to to spit out absolute URLs,
> rather than relative URLs?  I would like to do this for SEO purposes.
> Is there something that I have to subclass to get this to go, or is
> there a better hack out there to do this.
>
> Thanks!
>
> Kevin

If you are using named routes you can just used named_route_url instead
of named_route_path.

Or: link_to :action => 'index', :only_path => false

Or I think you can add this method to application.rb

def default_url_options
  { :only_path => false }
end
This topic is locked and can not be replied to.