0

[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

  • 1
    possible duplicate of [Devise update user without password](http://stackoverflow.com/questions/5113248/devise-update-user-without-password) – ROR Mar 26 '15 at 06:40

2 Answers2

0

You can go through link below

https://github.com/plataformatec/devise/wiki/How-To:-Allow-users-to-edit-their-account-without-providing-a-password

hope that helps

SRDP
  • 423
  • 8
  • 14
0
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

ROR
  • 441
  • 2
  • 13