ruby '2.6.5' rails '6.0.0 devise 4.7.2
edit_user_registration GET /users/edit(.:format) users/registrations#edit
I was able to confirm that it was edit_user_registration_path. Create a path for this with link_to.
Set before_action and configure_account_update_params. This time I will put my column.
before_action :configure_account_update_params, only: [:update]
def configure_account_update_params
devise_parameter_sanitizer.permit(:account_update, keys: [:nickname, :email, :password, :gender_id, :birth, :bloodtype_id, :emergencyperson, :emergencycall, :real_name, :real_name_kana, :phone_number])
end
Create an edit.html.erb file in users / registrations. I mostly use a copy of new.html.erb, but there are some additional notes. I'm using two devises so the directories are different, but with one devise the view will create edit.html.erb in devise / registrations.
Also change the path of form_with. Reference site here From the conclusion, it is the default setting of devise, but when updating the password, the current password is authenticated and updated.
<%= form_with model: @user, url: user_registration_path, method: :patch, class: 'registration-main', local: true do |f| %>
<div class="field">
<%= f.label :current_password %>
<%= f.password_field :current_password, autocomplete: "current-password" %>
</div>
Add this. When editing, you need an item to enter the password so far.
By adding this, the changed items were saved successfully. However, it is essential even if you do not change the password, so what is that? It's like that. I will continue to research and learn.
Recommended Posts