# Routes: Forward slashes in the :id

**URL:** <https://www.ruby-forum.com/t/routes-forward-slashes-in-the-id/129042>\
**Category:** Rails\
**Created:** [February 13, 2008, 7:13pm UTC](https://www.ruby-forum.com/t/routes-forward-slashes-in-the-id/129042 "2008-02-13T19:13:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [February 13, 2008, 7:13pm UTC](https://www.ruby-forum.com/t/routes-forward-slashes-in-the-id/129042/1 "2008-02-13T19:13:26Z")

</div>

Hi you all,

I have the following resource in my routes.rb

query\_pattern = Regexp.new(’(\w+[=]?\w\*[/]?)\*’)  
map.resources :queries, :path\_prefix =\>’/sdrs’, :name\_prefix=\>‘sdrs\_’,  
:requirements=\> {:id =\>query\_pattern}

To have and idea, my :id can be:  
key  
key=value  
key=value/key  
key=value/key=value… to the infinite and beyond…

However, when routing, an appears ocurred:  
no route found to match “/sdrs/queries/puertoa=1030/portb” with  
{:method=\>:get}

I mean, there are problems with the “/”, even though I read with  
:requirements the problems could be avoided…

Suggestions?

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [February 14, 2008, 3:23pm UTC](https://www.ruby-forum.com/t/routes-forward-slashes-in-the-id/129042/2 "2008-02-14T15:23:16Z")

</div>

On 2/13/08, Damaris F. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> key
> 
> Suggestions?

I think that in order to get open ended uri routing like that you need  
to use route globbing, (google for rails route glob).

I’m not sure that map.resource and map.resources allow globbing, so  
you might need to build the equivalent route the old fashioned way.

–  
Rick DeNatale

My blog on Ruby  
[http://talklikeaduck.denhaven2.com/](http://talklikeaduck.denhaven2.com/)

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [February 14, 2008, 4:29pm UTC](https://www.ruby-forum.com/t/routes-forward-slashes-in-the-id/129042/3 "2008-02-14T16:29:59Z")

</div>

Yes, this is exactly what I was doing right now (someone told me in the  
Spanish Rails forum).  
Thanks all 🙂

---

<div class="post-metadata">

**Author:** ![damaris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/2bfe46/32.png) [@damaris](https://www.ruby-forum.com/u/damaris)\
**Post date:** [February 14, 2008, 5:59pm UTC](https://www.ruby-forum.com/t/routes-forward-slashes-in-the-id/129042/4 "2008-02-14T17:59:57Z")

</div>

Uhm, however, I’m seeing a problem.  
My app has the REST approach with the respond\_to method.

So, when I type in the URL something like …/key/value.xml  
it takes the value as value.xml ( forgetting the XML).  
Everything works correctly from an HTTP client, such as curl, but not  
through the browser.

Damaris F. wrote:

> Yes, this is exactly what I was doing right now (someone told me in the  
> Spanish Rails forum).  
> Thanks all 🙂
