How to Prefixing a controller path in a route

Hi, I’ve been playing with routes and with Jamis B.'s plugin for host
based routing (http://svn.jamisbuck.org/rails-plugins/routing_tricks/).

Here’s what I have in routes.rb:

1 map.connect ‘’, :conditions => { :host =>
/www.example.(com|co.uk)/ },
2 :controller => “example/portal”
3
4 map.connect ‘:controller/:action/:id’,
5 :conditions => { :host =>
/www.example.(com|co.uk)/ },
6 :controller => “example/:controller”
7
8 # Default root
9 map.connect ‘’, :controller => “portal”
0
1 # Install the default route as the lowest priority.
2 map.connect ‘:controller/:action/:id.:format’
3 map.connect ‘:controller/:action/:id’
4

The first route at lines 1-2 fires on a request from
http://www.example.com”, causing the file
“controllers/example/portal_controller.rb” to be used.

Any other domain is picked up by line 13 and causes
controllers/portal_controller.rb" to be used.

The second route at lines 4-6 is supposed to fire on requests like
http://www.example.com/portal” but all I get here is
“controllers/portal_controller.rb” being used (I suspect this is via the
route at line 13).

I need my route at line 4-6 to respond to requests for
"http://www.example.com/controller/action/id and fire
“controllers/example/controller” ?

I am pretty sure the code on line 6 is wrong but have no idea what it
should be to make this work.

I want to handle overlays for several different domains.

Many thanks.

As a further clarification, the following works for
http://www.example/com/xyz :

map.connect ‘xyz/:action/:id’,
:conditions => { :host => /www.example.(com|co.uk)/
},
:controller => “example/xyz”

I want to do the below, but it does not work:

map.connect ‘:controller/:action/:id’,
:conditions => { :host => /www.example.(com|co.uk)/
},
:controller => “example/:controller”

Any help greatly appreciated :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs