# Using link\_to and :host

**URL:** <https://www.ruby-forum.com/t/using-link-to-and-host/174224>\
**Category:** Rails\
**Created:** [August 22, 2009, 8:32pm UTC](https://www.ruby-forum.com/t/using-link-to-and-host/174224 "2009-08-22T20:32:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [August 22, 2009, 8:32pm UTC](https://www.ruby-forum.com/t/using-link-to-and-host/174224/1 "2009-08-22T20:32:57Z")

</div>

Is it possible to use link\_to and specify a :host WHILE using a  
polymorphic URL?

I wanted to do this

\<%= link\_to item.name, item, :host =\> “[www.items.com](http://www.items.com)”, :only\_path =\>  
false rescue “” %\>

and ended up having to do this

\<%= link\_to item.name, url\_for(:controller =\> ‘item’, :action =\>  
‘show’, :id =\> item.id, :host =\> “[www.items.com](http://www.items.com)”, :only\_path =\> false)  
rescue “” %\>

No easier way?

---

<div class="post-metadata">

**Author:** ![kopf1988](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/74df32/32.png) [@kopf1988](https://www.ruby-forum.com/u/kopf1988)\
**Post date:** [August 22, 2009, 11:24pm UTC](https://www.ruby-forum.com/t/using-link-to-and-host/174224/2 "2009-08-22T23:24:27Z")

</div>

On Aug 22, 7:31 pm, kopf1988 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Is it possible to use link\_to and specify a :host WHILE using a  
> polymorphic URL?
> 
> I wanted to do this
> 
> \<%= link\_to item.name, item, :host =\> “[www.items.com](http://www.items.com)”, :only\_path =\>  
> false rescue “” %\>

You can use the polymorphic\_path helper, which allows you to pass  
extra routing options.

Fred
