I've put together some confusing methods when writing routing.
resources :users
Named routing path directory
↓ ↓ ↓
Prefix Verb URI Pattern Controller#Action
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PATCH /users/:id(.:format) users#update
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
Named routing | path | directory | |
---|---|---|---|
namespace | ○ | ○ | ○ |
module | × | × | ○ |
scope | × | ○ | × |
as | ○ | × | × |
Aim for a clean routes file!
reference: https://devblast.com/b/rails-5-routes-scope-vs-namespace
Recommended Posts