Updating `User` attributes without requiring password

前端 未结 9 1648
醉酒成梦
醉酒成梦 2021-01-30 17:27

Right now, users can edit some their attributes without having to enter their password because my validations are set up like this:

validates :password, :prese         


        
9条回答
  •  借酒劲吻你
    2021-01-30 18:24

    I had the same problem, and the solutions above didn't work for me. I found the real culprit in my case: I had an encrypt_password callback in my User model, which was setting the password to blank each time.

    before_save :encrypt_password

    I fixed it by adding a condition at the end for this call back:

    before_save :encrypt_password, :unless => Proc.new { |u| u.password.blank? }

提交回复
热议问题