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

**URL:** <https://www.ruby-forum.com/t/question-about-super-dynamic-routes-like-reqs-id/100292>\
**Category:** Rails\
**Created:** [November 23, 2005, 9:49pm UTC](https://www.ruby-forum.com/t/question-about-super-dynamic-routes-like-reqs-id/100292 "2005-11-23T21:49:33Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivanvega](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/9fc348/32.png) [@ivanvega](https://www.ruby-forum.com/u/ivanvega)\
**Post date:** [November 23, 2005, 9:49pm UTC](https://www.ruby-forum.com/t/question-about-super-dynamic-routes-like-reqs-id/100292/1 "2005-11-23T21:49:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ivanvega](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/i/9fc348/32.png) [@ivanvega](https://www.ruby-forum.com/u/ivanvega)\
**Post date:** [November 23, 2005, 10:21pm UTC](https://www.ruby-forum.com/t/question-about-super-dynamic-routes-like-reqs-id/100292/2 "2005-11-23T22:21:46Z")

</div>

On 11/23/05, Iván Vega R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> //…  
> 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.

I doubt it will work since you’re passing :state (the symbol, not the  
param value) to State. Even if that did work the way you’re wanting,  
it would execute DB queries just to match routes. I’d suggest doing  
this in the controller.

–  
rick  
[http://techno-weenie.net](http://techno-weenie.net)
