[Ruby] How to identify a path that is easy to make a mistake

less than 1 minute read

How to determine #path When searching for a path name, I usually use rails routes in the terminal,

               Prefix Verb URI Pattern Controller#Action
    new_admin_session GET /admins/sign_in(.:format) admins/sessions#new
        admin_session POST /admins/sign_in(.:format) admins/sessions#create
destroy_admin_session DELETE /admins/sign_out(.:format) admins/sessions#destroy

Search path name from prefix.

path name is missing

However, there are cases where the path name is not written like this.

               Prefix Verb URI Pattern
         edit_product GET /products/:id/edit(.:format) products#edit
              product GET /products/:id(.:format) products#show
                      PATCH /products/:id(.:format) products#update
                      PUT /products/:id(.:format) products#update
                      DELETE /products/:id(.:format) products#destroy
                 cart GET /carts/:id(.:format) carts#show

Cannot find the pathname of products#destroy, products#update. In this case, the path name will be product_path. You can go back up until the path name appears in prefix.