Using link_to and :host

115 views
Skip to first unread message

kopf1988

unread,
Aug 22, 2009, 2:31:28 PM8/22/09
to Ruby on Rails: Talk
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", :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", :only_path => false)
rescue "" %>

No easier way?

Frederick Cheung

unread,
Aug 22, 2009, 5:22:48 PM8/22/09
to Ruby on Rails: Talk


On Aug 22, 7:31 pm, kopf1988 <kopf1...@gmail.com> 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", :only_path =>
> false rescue "" %>
>

You can use the polymorphic_path helper, which allows you to pass
extra routing options.

Fred
Reply all
Reply to author
Forward
0 new messages