# Rails: Does the option :host work in link\_to?

**URL:** <https://www.ruby-forum.com/t/rails-does-the-option-host-work-in-link-to/105069>\
**Category:** Ruby\
**Created:** [May 25, 2007, 2:27pm UTC](https://www.ruby-forum.com/t/rails-does-the-option-host-work-in-link-to/105069 "2007-05-25T14:27:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![shiwei\_zhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/eb8c5e/32.png) [@shiwei\_zhang](https://www.ruby-forum.com/u/shiwei_zhang)\
**Post date:** [May 25, 2007, 2:27pm UTC](https://www.ruby-forum.com/t/rails-does-the-option-host-work-in-link-to/105069/1 "2007-05-25T14:27:39Z")

</div>

Hi,

I used the following code line in a View file on machine  
[http://xx.test.com:7777](http://xx.test.com:7777):  
\<%= link\_to “GoToAnotherHost”, { :protocol =\> “http”, :host =\>  
“[app1books.test.com:7777](http://app1books.test.com:7777)”, :controller =\> “admin”, :action =\> “list” }  
%\>  
However the result is: the link “GoToAnotherHost” is always pointed to  
[http://xx.test.com:7777/admin/list](http://xx.test.com:7777/admin/list) rather than  
[http://app1books.test.com:7777/admin/list](http://app1books.test.com:7777/admin/list). I.e., the :host doesn’t take  
effect at all!  
What’s wrong with this? Do you meet the same problem?

Many Thanks!  
Shiwei

---

<div class="post-metadata">

**Author:** ![shiwei\_zhang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/eb8c5e/32.png) [@shiwei\_zhang](https://www.ruby-forum.com/u/shiwei_zhang)\
**Post date:** [May 25, 2007, 3:56pm UTC](https://www.ruby-forum.com/t/rails-does-the-option-host-work-in-link-to/105069/2 "2007-05-25T15:56:02Z")

</div>

shiwei zhang wrote:

> Hi,
> 
> I used the following code line in a View file on machine  
> [http://xx.test.com:7777](http://xx.test.com:7777):

Rails questions are best asked on the Rails mailing list, where you will  
get a better, faster, answer; details may be found at

> **[Ruby on Rails](https://rubyonrails.org)**
>
> A web-app framework that includes everything needed to create database-backed web applications according to the Model-View-Controller (MVC) pattern.

–  
James B.

“Hackers will be expelled”

- The Breakfast Club (1985)
