Example I have had configured my routes as
match '/cellphones/:permalink/:charger', :controller => 'mycontroller', :action => 'myaction'
resources :cellphones
Everything ok when I put something like this localhost/cellphones/nokia3323/lion but I can’t edit a cellphone because have the same structure localhost/cellphones/edit/4
Routes that are defined earlier take precedence, so you could make the edit route accessible again by reversing the order that you’ve declared your routes in. Since a route of
/cellphones/edit/:idis more restrictive than/cellphones/:permalink/:charger, the edit route will match if the second part of the route is “edit” and pass through to your other route if it’s something else.However, you most likely don’t actually have a
/cellphones/edit/:idroute, because what’s created byresources :cellphonesis/cellphones/:id/editwhich is much harder to distinguish from/cellphones/:permalink/:chargersince both have the wildcard part of the route as the second segment.The easiest way the fix the problem would be to change the
/cellphones/:permalink/:chargerroute so it’s easier to distinguish. You could use something like/cellphones/p/:permalink/:charger(“p” for permalink), or anything else that’s easy to distinguish from the RESTful routes created byresources.There’s a few other ways you could approach it as well, such as using segment contraints or adding more restful actions.