How to edit user registrations with devise
The password handling in devise is designed so that it cannot be edited (updated) from the viewpoint of security, and even if you try, you cannot edit it and you will be forcibly logged out. Also, even if you edit the view and make it impossible to input, validation will be activated. So you have to turn off the validation when editing (update).
ruby 2.6.5 rails 6.0.0 devise 4.7.3
install devise rails g devise: view model name Routing settings
Now you are ready to go.
First, when you install the device, it will cancel the validation that is set by default.
Devalidation on model
devise :database_authenticatable, :registerable, :recoverable, :rememberable :validatable #← Delete this#
Removed: validatable as it controls device validation. You can now change it manually. You can edit (update) in this state, but as it is, everything is off, so the validation at the time of new registration (create) is also off.
Since we want to activate validation when newly registering (create), specify the validation timing using the on option.
validates :password, on: :create #← create In other words, turn it on only when saving.# validates :nickname, presence: true validates :name, presence: true
With this, it is possible to turn off when editing (update) and on when newly registering (create).
By the way, the password change function itself can be done by selecting "Current password" → "New password" ,,,, but passwords and e-mail addresses require strict security. We recommend that you create a dedicated page instead of treating it together with pages such as name and address.
devise is very convenient when implementing user management functions, and various functions such as user registration are standard equipment. However, various operations are required to customize the specifications to your liking.
I am a beginner in programming, but I am posting an article in the hope that it will help people who want to become engineers as well as myself. See you next time ~