So far, the best I could come up with is this:
map.resources :users map.resources :users_by_login, :controller => "User", :only => [:show, :edit, :update, :destroy], :requirements => {:by_login => true}
Regular RESTful routes are created for users, and in addition, the users_by_login resource adds the following routes (and only those):
GET /users_by_login/:id/edit GET /users_by_login/:id/edit.:format GET /users_by_login/:id GET /users_by_login/:id.:format PUT /users_by_login/:id PUT /users_by_login/:id.:format DELETE /users_by_login/:id DELETE /users_by_login/:id.:format
These routes are actually displayed in the UserController ( show / edit / update / destroy methods only). An additional by_login parameter (equal to true ) has been added: in this way, the UserController methods can determine whether the id parameter specifies a login or identifier.
He does the job, but I want a better way.
source share