Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

has_secure_password not Encrypting password_digest Ruby on Rails

I have commented everything out of my model except:

has_secure_password

and with my migration I have added:

t.string "password_digest"

to my users database.

When I create a user in the rails console and try to save it however, the password doesn't encrypt. It appears in my database as the password that I entered. Could someone please tell me how to get has_secure_password to encrypt my password? Am I missing something simple? I have the bcrypt gem installed.

like image 728
dinosaurW Avatar asked Nov 29 '25 07:11

dinosaurW


1 Answers

Yes. For others that come by this post and aren't quite sure what you mean.

You don't assign a password to password_digest

You assign it to password

When you add has_secure_password to your model, it automatically adds a virtual attribute called password. When you assign a value to password, it will encrypt and save into password_digest.

like image 187
doz87 Avatar answered Dec 02 '25 03:12

doz87



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!