I make on the site the ability to change the password to the user. The fact is that the password is hashed in the model with the bcrypt jam method built into the model has_secure_password. And when changing the password, the password should be changed only if the old password (which is currently set) coincided with the entered one. And, as we know, the password hash is stored in the database, so a simple comparison of the type
if(@user.password_digest == params(:password)) We will not succeed. Actually, hence the question: how to compare the new password value with the hashed password in the database, using has_secure_password in the model?