Creating a local copy of the routes.rb file to speed up your grepping of the routes

Public, Command Line, Rails General

harrylevine

Created: Oct 07, 2016     Updated: Oct 08, 2016


Grepping your routes.rb file, for decent size projects, can take a long time. One solution to speed up this process is to create a local copy of the current state of your routes.rb file, and grep that file as needed.

1 - Create the new local_routes file one directory above your project's directory.

This way the new local_routes file will not continuously be an untracked file in your project's git status.

$ rake routes > ../local_routes

That created a file called local_routes; however, you can use any name here.

2 - Grep the new local_routes

For example, in order to grep the file for user_attendance_edits, call:

$ cat ../local_routes | grep user_attendance_edits

Important

This file will not automatically remain in step with your routes. You'll want to do that manually, as needed. To update the new routes file, again call:

$ rake routes > ../local_routes

Note that > both creates a new file, as well as replaces the content of the existing one.