How To Search Rails Routes

If you have a big Rails application, it might take a while to run the standard rake routes command in your Terminal. Plus, once you run “rake routes”, you have to look through all of them to find the ones for only the model you need.

So let’s say you only want to know which routes have a “/user” in them. Simply type rake routes | grep user in your Terminal. If you’re using devise with your user model, you’ll only get the following search results:

The “grep” command is the standard way to run a search in the Terminal. Combining it with rake routes makes it easy to see only the routes you want.

Enjoy the article? Join over 20,000+ Swift developers and enthusiasts who get my weekly updates.