Make routes with e-mail address


I have a RESTful controller that works when using a numeric ID. Now I
would like to accept user login names as ID and for some of the cases
this is an e-mail address. In short it boils down to routing the
request URL

GET /users/
DELETE /users/


:controller => :users, :action => :show
:controller => :users, :action => :delete

And so on. Does anyone know how to do this. Grateful for any insight
on this.


There's no reason why you couldn't just pass those as the ids to the
url helpers, but you need to update your controller

user = User.find(params[:id])
user = User.find_by_email(params[:id])

Hi and thanks for the input. The problem was that I wanted to use .xml
as :format which was not possible without customized routes. I did
some reading and came up with a solution which I post if anyone else
has a similar problem:

  map.connect "customers/:login.:format",
              :controller => "customers",
              :action => "show",
              :conditions => {:method => :get},
              :login => /\b[\w.%-]+@[\w.%-]+\.[a-zA-Z]{2,4}/

Kindest regards