Routing: requiring requirements for non-existent params?

With this route:
map.connect ‘items/:subject/:id’,
:controller=>‘items’, :action=>‘show_redirect’,
:requirements => {:subject => /.+/, :id => /\d+/}

Is it possible to have it match these URLs:

items/biology/123
items/chemistry/234
items/math/456

But not these:

items/new
items/list

The problem is that :requirements only applies if that
param exists. I’d like to make it so that that route
only applies if all params do in fact exist. I’d do it
with redirects in Lighty, but I want to send 301
redirects and I’m not sure what code redirect.url
sends (probably 302).

Thanks for any help!
csn


Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around

On 2/8/06, CSN [email protected] wrote:

redirects and I’m not sure what code redirect.url
sends (probably 302).

Thanks for any help!
csn

This might be a crazy hack, but what happens if you change the route to
be:
map.connect ‘items/:subject/:id’, :id => ‘crazy’,
:controller=>‘items’, :action=>‘show_redirect’,
:requirements => {:subject => /.+/, :id => /\d+/}

The idea being that :id defaults to a value that doesn’t match the
requirements.
Totally untested, may not work, etc.