[RUBY] [Rails] devise-related routing summary

Since devise is also a useful function, I am confused about the routing that each method automatically generates. If you have the same problem, please do.

devise_for

routes.rb


  devise_for :users

python


$ rails routes

Prefix                   Verb   URI Pattern                    Controller#Action

new_user_session         GET    /users/sign_in(.:format)       devise/sessions#new
user_session             POST   /users/sign_in(.:format)       devise/sessions#create
destroy_user_session     DELETE /users/sign_out(.:format)      devise/sessions#destroy
user_password            POST   /users/password(.:format)      devise/passwords#create
new_user_password        GET    /users/password/new(.:format)  devise/passwords#new
edit_user_password       GET    /users/password/edit(.:format) devise/passwords#edit
                         PATCH  /users/password(.:format)      devise/passwords#update
                         PUT    /users/password(.:format)      devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)        devise/registrations#cancel
       user_registration POST   /users(.:format)               devise/registrations#create
   new_user_registration GET    /users/sign_up(.:format)       devise/registrations#new
  edit_user_registration GET    /users/edit(.:format)          devise/registrations#edit
                         PATCH  /users(.:format)               devise/registrations#update
                         PUT    /users(.:format)               devise/registrations#update
                         DELETE /users(.:format)               devise/registrations#destroy

resources: Comparison with users

Action name request resources devise_for
new GET /users/new /users/sign_up(.:format)
edit GET /users/:id/edit /users/edit(.:format)
show GET /users/:id None
index GET /users None
create POST /users /users(.:format)
update PATCH / PUT /users /users(.:format)
destroy DELETE /users /users(.:format)

devise_scope

routes.rb


  devise_scope :user do
    get 'signin' => 'devise_token_auth/sessions#new'
    post 'signin' => 'devise_token_auth/sessions#create'
    post 'signup' => 'users#create'
    put 'update' => 'users#update'
  end

python


$ rails routes

Prefix Verb   URI Pattern                  Controller#Action

signin GET    /signin(.:format)            devise_token_auth/sessions#new
       POST   /signin(.:format)            devise_token_auth/sessions#create
signup POST   /signup(.:format)            users#create
update PUT    /update(.:format)            users#update

mount_devise_token_auth_for

routes.rb


  mount_devise_token_auth_for 'User', controllers: {
    registrations: 'users'
  }

python


$ rails routes

Prefix Verb   URI Pattern                  Controller#Action

signin GET    /signin(.:format)            devise_token_auth/sessions#new
       POST   /signin(.:format)            devise_token_auth/sessions#create
signup POST   /signup(.:format)            users#create
update PUT    /update(.:format)            users#update

Recommended Posts

[Rails] devise-related routing summary
Rails 6.0 Routing Summary
[Rails] Summary of complicated routing configurations
Rails Routing Basics
rails db: 〇〇 Summary
Catch Rails Routing Error
[Rails] Migration command summary
[Rails] rails db command summary
rails error resolution summary
[Note] Rails3 routing confirmation
Understand Rails "shallow" routing
[Rails] Complete routing settings
Organize Rails routing using draw
Rails Tutorial (4th Edition) Summary
Rails routing controller view relationship
How to write Rails routing
Ruby on Rails validation summary
Introduction to RSpec-Everyday Rails Summary-
Rails singular resource routing by resource
Ruby on Rails Overview (Beginner Summary)
[Rails Struggle/Rails Tutorial] Summary of Rails Tutorial Chapter 2
Ruby on Rails variable, constant summary
rails tutorial chapter 10 summary (for self-learning)
Set Rails routing other than id
Summary
Ruby On Rails devise routing conflict
routing
[Rails] AWS deployment error encounter summary
Rails Tutorial 6th Edition Learning Summary Chapter 10
Rails Tutorial 6th Edition Learning Summary Chapter 7
Rails Tutorial 6th Edition Learning Summary Chapter 4
[Ruby on Rails] 1 model CRUD (Routing Main)
Rails Tutorial 6th Edition Learning Summary Chapter 9
Rails Tutorial 6th Edition Learning Summary Chapter 6
[Rails Struggle/Rails Tutorial] Summary of Heroku commands
Rails / users /: id / to / {random_srting}: Dedefault Routing
Rails Tutorial 6th Edition Learning Summary Chapter 5
Rails Tutorial 6th Edition Learning Summary Chapter 2
[rails] How to configure routing in resources
Rails: A little summary about data types
Rails Tutorial 6th Edition Learning Summary Chapter 3
[Rails] Method summary for conversion / verification / search
Rails Tutorial 6th Edition Learning Summary Chapter 8