Does the option :host work in link_to?


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!

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"

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs