Routing by subdomain problem

hi everyone,
I’m trying to set up a routing command so that the ‘www’ subdomain would
always be directed to my ‘site’ controller, while all other subdomain
urls (like username.localhost.com)be sent to the ‘user’ controller.

I have installed the request routing plugin
(http://wiki.rubyonrails.org/rails/pages/Request+Routing)

and this is what i have in routes.rb:
map.connect ‘’, :controller => ‘site’, :requirements => { :subdomain =>
‘www’}
map.connect ‘’, :controller => ‘user’, :action => ‘index’

It seems that no matter what subdomain I call (www.localhost.com /
myuser.localhost.com) it always gets routed to the site controller.

Also, how is it possible to route the following url to an account
controller:
www.localhost.com/account/logout?
there is no id in this url - will the following route work:
map.connect ‘:controller/:action/’?
How can I only route it if the controller is ‘account’?

Thanks!
Ehud

On Mar 17, 2007, at 11:13 PM, Ehud R. wrote:

I have installed the request routing plugin
(http://wiki.rubyonrails.org/rails/pages/Request+Routing)

and this is what i have in routes.rb:
map.connect ‘’, :controller => ‘site’, :requirements =>
{ :subdomain =>
‘www’}

It is right, only :requirements should be :conditions.

Also, how is it possible to route the following url to an account
controller:
www.localhost.com/account/logout?
there is no id in this url - will the following route work:
map.connect ‘:controller/:action/’?
How can I only route it if the controller is ‘account’?

It just works with default routes, note that you don’t need it in the
canonical CRUD’s index/list actions.

– fxn

hmmm, it seems that even when I change it to :conditions it still routes
to the site/index:

map.connect ‘’, :controller => ‘site’, :action=>‘index’, :conditions =>
{ :subdomain => ‘www’}

and the url i access is: test.localhost.com:3001.
I get routed to the main site instead of to the account controller.

Any idea why?
Thanks!

Is there anything I should do excpet plguin/install the request_routing
plug in?
Do i have to use it somewhere in my application?

On Mar 17, 2007, at 11:55 PM, Ehud R. wrote:

I get routed to the main site instead of to the account controller.

Any idea why?

It’s strange, these routes are working for me:

map.connect ‘’, :controller => “public”, :action =>
‘index’, :conditions => {:subdomain => ‘www’}
map.connect ‘’, :controller => “invoices”, :action => ‘new’

They seem analogous to yours.

– fxn

On Mar 18, 2007, at 12:08 AM, Ehud R. wrote:

Is there anything I should do excpet plguin/install the
request_routing
plug in?

The server needs a restart to load the plugin (that happens with any
plugin), nothing else.

– fxn