Listing
rails routes
and
interpreting is quite troublesome
if you are using a small screen on terminal.
Rails 6 adds support to show rails routes
in
an expanded format with --expanded option.
Before Rails 6
Rails routes list all the routes defined for a Rails application with command
given below.
This lists down prefix, URI pattern, Controller information of each route
in a table format.
Each line of information goes to next line if you are using a small terminal
screen.
We have to track a row to interpret prefix, URI pattern or controller
of
certain row to interpret information.
Thus, it is quite difficult to interpret such information.
Rails Routes Expanded option
Rails 6
introduces expanded
option
to be able to list down rails routes in an expanded format
where it gets easy to interpret information of a certain route.
To view Rails routes in an expanded format,
pass --expanded option to rails routes command as given below.
This will list down routes as given below.
List same routes shown in the post above.
These routes also show a route number.
It’s just a number that indicates ordering
in
which these routes are defined
along with
prefix, verb, URI and controller#action.
As we can see,
expanded option on rails routes
outputs information in a table format
which is much more readable
and
easy to follow than earlier version.