Routes and Requirements parameter question

I have done very little with customizing routes so this is new for me.

I would like to send users to my users controller only if it follows a
particular pattern. I think that I might be able to use requirements
for this?

I’ve got this so far, but it’s not quite working.

map.user ‘:user’, :controller => ‘users’, :action => ‘show’,
:requirements => {:user => /[-+]/ }

I want this url to work www.domain.com/first-last

I want this domain to fail www.domain.com/firstlast

The problem is that “firstlast” goes to the users controller and fails.
The only way to get out of it is a rescue with a redirect to a 404 page.
I’d like to handle this in the routes instead of going to the
controller.

Is that possible and if so, any help with what I have so far would be
appreciated.

Thanks.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs