Route 1st domain to a controller, 2nd domain to con/act/id


#1

I’m having trouble with mapping a first domain to:

map.connect ':action', :controller => 'admin'

I can get that to work, and I’d be fine if there’s only one domain
pointing to my app.

However, I will point several domains to the app, so I only want that
route for one domain.

I’ve tried:

map.connect ':action', :controller => 'admin' if @request.host == 

domain.com

but I get an error about nil.host. I’m not sure but it seems @request
is undefined in routes.rb.

How might I get this done?

Thanks,
Bill


#2

I’ve tried:

map.connect ':action', :controller => 'admin' if @request.host ==

domain.com

but I get an error about nil.host. I’m not sure but it seems @request
is undefined in routes.rb.

How might I get this done?

Hello Bill,

You should take a look at the Rails “Request Routing” plugin
mentioned in the following post:
http://weblog.rubyonrails.org/articles/2006/05/22/dan-webbs-request-
routing-plugin

It looks like it will fullfill your need.

Roman


#3

You should take a look at the Rails “Request Routing” plugin
mentioned in the following post:
http://weblog.rubyonrails.org/articles/2006/05/22/dan-webbs-request-
routing-plugin

That looks good. A little more digging reveals routes.rb is set once,
before @request is set.

The plugin is a nice work around.

Thanks,
Bill