Odd Routing - How To?

I am working on an app with a requirement that has yielded an unexpected
problem for Rails routing.

We have several controllers that handle regional data (one controller
per data type - weather, demographics, etc). The problem is that there
is one region who’s actions and output are different.

We intend to create two controllers for each data type (i.e.
weather_controller to handle requests for all regions but the one and
regionx_weather_controller with its own special methods, data, and
templates).

So, with that in mind, the requirement is to have the url of the form:

:region/:controller/:action

That’s great for the main regions but this bastard region needs a
routing statement like:

map.connect ‘regionx/:special/:action’, :controller => ‘regionx_’ +
:special

(which, of course, doesn’t work - or I wouldn’t be asking this)

Apparently :special gets packaged up as a param and sent to the
controller (if I name a valid one) but I can’t access the symbol here
for some reason.

On Jan 2, 2006, at 10:52 PM, Chris P. wrote:

weather_controller to handle requests for all regions but the one and
map.connect ‘regionx/:special/:action’, :controller => ‘regionx_’ +
:special

(which, of course, doesn’t work - or I wouldn’t be asking this)

Apparently :special gets packaged up as a param and sent to the
controller (if I name a valid one) but I can’t access the symbol here
for some reason.

Yeah, that’s not going to work. Unfortunately there are only two
options (that I know of–if someone else has something, please chime
in).

Option 1:

map.connect ‘regionx/weather/:action’, :controller => ‘regionx_weather’
map.connect ‘regionx/demographics/:action’, :controller =>
‘regionx_demographics’
map.connect ‘regionx/etc/:action’, :controller => ‘regionx_etc’

Option 2:

map.connect ‘regionx/:special/:action’, :controller =>
‘regionx_dispatcher’

class RegionxDispatcherController < ApplicationController
def index
render_component :controller => ‘regionx_’ + params[:special].to_s
end
end

Duane J.
(canadaduane)
http://blog.inquirylabs.com/

I’m looking to accomplish something similar to this myself, only my
situation is a little different. Ideally, I’d like to have a whole new
type of controller so I can have controllers with the same name in
different “namespaces”.

In other words, I can have a foo_controller and a foo_xcontroller, where
the latter is used if x is in the url. I’ve been trying to hack Routes
to handle something like this, but I was hoping I could find some help
and ideas here.