Ruby on Rails: Why does the user's encrypted password get changed in the DB when I use the “toggle” method on the admin attribute?

前端 未结 3 904
时光说笑
时光说笑 2021-01-07 04:28

I just finished Hartl\'s Rails Tutorial book and I\'m using his account authentication logic in my first rails app. However, when I make a new user account and set it as an

3条回答
  •  -上瘾入骨i
    2021-01-07 04:42

    Not sure what is going on specifically. Could be that the password is getting encrypted again using a different salt (which is based on the time). Try adding debugger to the first line of encrypt_password and then run the same code from the console to see if the password is getting encrypted when you run toggle!

提交回复
热议问题