Question about "super dynamic" routes, like :reqs => {:id =>


#1

Hi,

I want my app to handle different possibilities for a path. I know I can
easily do this inside my app, as I just evaluate the generic path and
render the desired component.

However, I was wondering if this was possible directly in routes.rb

Suppose I want to handle these three kind of URLs:

//…
//…
//…

Then, maybe I could do something like:

map.connect ‘:state/*path_info’, :controller => ‘states’, :requirements
=> {not State.find(:first, :conditions => ‘name =
‘#{:state}’’).empty?}

That would supposedly look if there was a state with that name, and use
that controller if there was. I’d use a similar approach for the other
routes.

I haven’t tried if it works yet (if it does I’d be extremely surprised
if my example worked!), but if it did, would you recommend doing
something like this or handling it directly inside a controller?

Thanks!

Ivan V.