Forum: Ruby on Rails Route 1st domain to a controller, 2nd domain to con/act/id

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
0f23274e975611727e4ad46d745d298e?d=identicon&s=25 Bill (Guest)
on 2006-05-27 11:00
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
Bca6763730989267ae5c7cfa6503e177?d=identicon&s=25 Roman LE NEGRATE (Guest)
on 2006-05-27 11:46
(Received via mailing list)
> 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/...
routing-plugin

It looks like it will fullfill your need.


Roman
0f23274e975611727e4ad46d745d298e?d=identicon&s=25 Bill (Guest)
on 2006-05-27 15:15
> You should take a look at the Rails "Request Routing" plugin
> mentioned in the following post:
> http://weblog.rubyonrails.org/articles/2006/05/22/...
> 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
This topic is locked and can not be replied to.