Rails 現在定義されているルート一覧を表示する

Railsで現在定義されているルート一覧を表示するには、rake routesを使います。

$ rake routes

ルートファイルでresourcesを定義した場合

@routes.rb

resources :posts

ルート一覧を確認すると下のような感じで表示されます。

rake routes
   Prefix Verb   URI Pattern               Controller#Action
    posts GET    /posts(.:format)          posts#index
          POST   /posts(.:format)          posts#create
 new_post GET    /posts/new(.:format)      posts#new
edit_post GET    /posts/:id/edit(.:format) posts#edit
     post GET    /posts/:id(.:format)      posts#show
          PATCH  /posts/:id(.:format)      posts#update
          PUT    /posts/:id(.:format)      posts#update
          DELETE /posts/:id(.:format)      posts#destroy