I've got a user model for my app, and it has effectively used has_secure_password
up til this point. has_secure_password
necessitates a password_digest
column, and herein lies my recent problem.
I wanted to create a "role" column of type string that separates admins from users - but after migrating, my password_digest
got corrupted so that I get an invalid hash error whenever I try to use it in my app. In mysql everything is fine (the password_digest
values haven't changed) but in rails console the value returned by User.first.password_digest
is something along the lines of:
\#BigDecimal:59d0c60,'0.0',9(18)
Furthermore, unless I change the type of role from string, it gets similarly messed up (although like password_digest
, it's totally fine in mysql regardless). Rolling back the migration and getting rid of the "role" column causes password_digest
to go back to normal as far as rails console is concerned.
What is going on here?
Here's my database schema:
Here's the result of a sql query fed directly to mysql:
Here's the result of the same query through rails (first time):
Here's the result of the same query through rails (after first time):