# How to List and Filter Routes in Ruby on Rails

*Published on July 18, 2024*

---


> This post is part of my&nbsp;[handbook on the Rails Router](/tag/router).

You can list all the routes in your Rails application by running the&nbsp;`bin/rails routes`&nbsp;command in the terminal.

```bash
$ bin/rails routes
              Prefix  Verb   URI Pattern                    Controller#Action
              sidekiq        /sidekiq(.:format)             Sidekiq::Web
        sidekiq_admin        /admin                         Sidekiq::Admin
    new_user_session  GET    /users/sign_in(.:format)       devise/sessions#new
        user_session  POST   /users/sign_in(.:format)       devise/sessions#create
destroy_user_session  DELETE /users/sign_out(.:format)      devise/sessions#destroy
    new_user_password GET    /users/password/new(.:format)  devise/passwords#new
```

The output shows a table with four columns:

1. `Prefix`: Name of the route
2. `Verb`: HTTP Method such as GET, POST, etc.
3. `URI Pattern`: URL pattern to match
4. `Controller#Action`: Names of the controller class and action method

### Filtering Routes

To filter the routes, you can use the grep option, by passing the&nbsp;`-g`&nbsp;flag. The following commands filters all the routes containing the term&nbsp;`songs`.

```bash
$ bin/rails routes -g songs
Prefix Verb URI Pattern               Controller#Action
 songs GET  /songs(/:genre)(.:format) songs#index {:genre=>"rock"}
```

### View in a Browser

Alternatively, you could also find all the routes by visiting the&nbsp;`/rails/info/routes`&nbsp;path on a running Rails application.

![rails-routes-info.png](https://writesoftwarewell.com/media/qtql5qd28cf0745irnthwx5dxxxe.png "rails routes info")

