# Url\_for and routes with host

**URL:** <https://www.ruby-forum.com/t/url-for-and-routes-with-host/127119>\
**Category:** Rails\
**Created:** [January 25, 2008, 2:54am UTC](https://www.ruby-forum.com/t/url-for-and-routes-with-host/127119 "2008-01-25T02:54:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![etlund](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/848f3c/32.png) [@etlund](https://www.ruby-forum.com/u/etlund)\
**Post date:** [January 25, 2008, 2:54am UTC](https://www.ruby-forum.com/t/url-for-and-routes-with-host/127119/1 "2008-01-25T02:54:14Z")

</div>

I have a route the looks like this:

map.preview\_profile ‘/profile/:client/:profile’, :controller =\>  
‘profiles’, :action =\> ‘pub\_view’

if I do url\_for(:controller =\> ‘profiles’, :action =\>  
‘pub\_view’, :client =\> ‘client-xyz’, :profile =\> ‘profile1’ )

I get this: “/profile/client-xyz/profile1”

However, if I change my route to this:

map.preview\_profile ‘/profile/:client/:profile’, :controller =\>  
‘profiles’, :action =\> ‘pub\_view’, :host =\> ‘[www.example.com](http://www.example.com)’  
(I added the :host option)  
the same url\_for returns this:

/profiles/pub\_view?client\_permalink=client-  
xyz&profile\_permalink=profile1

I’ve also tried  
url\_for(:host =\> ‘[www.example.com](http://www.example.com)’, :controller =\> ‘profiles’, :action  
=\> ‘pub\_view’, :client =\> ‘client-xyz’, :profile =\> ‘profile1’ )

with the same results.

So my conclusion is that Routes and URL generation is broken if you  
specify a :host in the Route. Is that correct?

FWIW, I’m not really doing url\_for, I’m trying to use expire\_page but  
that relies on url\_for.

Thanks for any help or work-arounds for this issue.

Eric Lund
