Routes: Forward slashes in the :id

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?

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.

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

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 Fuentes wrote: