简体   繁体   中英

i want to update the user profile using the devise gem without update the password

[my controller] this question seems to be similar to one of the question ask on the same topic but it different because the answer given in that is not work for me

i want to update the user profile but when i try to update using the devise gem or override the update action it wouldn't be update it give error password_confirmation can'nt be blank

 def update 
   binding.pry
   @user = User.where(:id => current_user.id)
  if @user.update(update_params)
    render :json => {:user => @user.to_json }
   else
    render :json => {:error => @user.errors.full_messages.first}
  end
end  

 private
   def user_params
    params.permit(:first_name, :last_name, :email, :phone_number,:password_confirmation, :password, :city) 
   end

def update_params
  params.permit(:first_name, :last_name,:phone_number, :city) 
end

end

class RegistrationsController < Devise::RegistrationsController

  protected

  def update_resource(resource, params)
     resource.update_without_password(params)
  end
end

For more information, please have a look into this link

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM