Forum: Ruby on Rails Does the option :host work in link_to?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
5f37c4293404055bf287507bad786c79?d=identicon&s=25 Shiwei (Guest)
on 2007-05-28 11:39
(Received via mailing list)

I used the following code line in a View file on machine
<%= link_to "GoToAnotherHost", { :protocol => "http", :host =>
"", :controller => "admin", :action => "list" }
However the result is: the link "GoToAnotherHost" is always pointed to rather than
I.e., the :host doesn't take effect at all!
What's wrong with this? Do you meet the same problem?

Many Thanks!
15eb647956921a6bc9655c3513feb139?d=identicon&s=25 lanzm (Guest)
on 2007-05-28 12:05
(Received via mailing list)
use :only_path and the procotol like "http://" (see below) not what
one would expect, but its mentioned in the manual.

    <%= link_to "GoToAnotherHost",
      :only_path => false,
      :protocol => "http://",
      :host => "",
      :controller => "admin",
      :action => "list"
588ab1c0a5610a7e160a3b101abb91e6?d=identicon&s=25 MichaelLatta (Guest)
on 2007-05-28 17:08
(Received via mailing list)
You should be able to link_to a string rather than a hash.  Since
routes vary from site to site the hash would be risky in any event.

This topic is locked and can not be replied to.