Expanded routing info in Rails
When using rails and wanting to know how one of your routes plays out, it's very easy to do a quick cli call to rails routes
. This gives an overview of all routes in the app.
> rails routes
Prefix Verb URI Pattern Controller#Action
rails_health_check GET /up(.:format) rails/health#show
restaurants GET /restaurants(.:format) restaurants#index {:format=>:json}
However if we provide the --expanded
flag, we get a more verbose output with also tells you exactly where in the routes file it was declared.
> rails routes --expanded
--[ Route 1 ]--------------------------------------------------------------------
Prefix | rails_health_check
Verb | GET
URI | /up(.:format)
Controller#Action | rails/health#show
Source Location | config/routes.rb:6
--[ Route 2 ]--------------------------------------------------------------------
Prefix | restaurants
Verb | GET
URI | /restaurants(.:format)
Controller#Action | restaurants#index {:format=>:json}
Source Location | config/routes.rb:11
This could be exceptionally helpful when breaking up large routing files in Rails
Tweet