When I introduced devise in Rails5, I had a problem that the password change screen generated by devise could not be displayed properly, so I will leave it as a memorandum.
--How to display the password change screen before and after logging in to devise
Usage environment
ruby 2.5.7
rails 5.2.4
After installing devise, if you check the routing using the "rails routes" command on the console, it will be displayed in the following form.
$ 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
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
user_password PATCH /users/password(.:format) devise/passwords#update
PUT /users/password(.:format) devise/passwords#update
POST /users/password(.:format) devise/passwords#create
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
user_registration PATCH /users(.:format) devise/registrations#update
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
POST /users(.:format) devise/registrations#create
At this time, the routing for displaying the password change screen is
edit_user_password GET /users/password/edit(.:format)
It may seem like (I did), but there is actually another routing for the change screen. that is
edit_user_registration GET /users/edit(.:format)
is. The difference between the two is
edit_user_password GET /users/password/edit(.:format) #Password change screen before login
edit_user_registration GET /users/edit(.:format) #Password change screen after login
... apparently ...
Let's use each correctly, such as specifying the path in "link_to" (although I feel that I basically use only the one after login).
Recommended Posts