Search⌘ K
AI Features

Never Configure Routes That Aren’t Being Used

Understand how to avoid defining unused routes in Rails by using the only parameter with resources. Learn to maintain clear, manageable routes, improve bin/rails routes output, and reduce errors caused by incorrect URL helpers.

Why shouldn’t we use bin/rails routes?

Running bin/rails routes on an app is a great way to get a sense of its size, scope, and purpose. If the output of that command lies as ours currently does, it’s not helpful. It creates confusion. More than that, it allows us to use a URL helper that will happily create a route that will never work.

Using the only: parameter

The solution is to use the optional only: parameter to resources. This parameter ...