0

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: Database schema

Here's the result of a sql query fed directly to mysql: MySQL query

Here's the result of the same query through rails (first time): Rails query

Here's the result of the same query through rails (after first time): Rails query2

cognalog
  • 440
  • 5
  • 8
  • I don't believe anybody can debug your situation from your description alone... there's just not enough context without seeing some code and table definitions. – Jim Garrison May 05 '12 at 05:48

1 Answers1

0

Looks like your query is getting auto-explained. See the documentation here http://guides.rubyonrails.org/active_record_querying.html#automatic-explain

Wizard of Ogz
  • 12,543
  • 2
  • 41
  • 43
  • If that's the problem, I'm not sure where to put Base.silence_auto_explain...does it go in a file? – cognalog May 05 '12 at 20:42
  • I think the most important thing to find out here is why auto-explain is getting triggered. I'm led to believe that something more than just the database schema was changed. I agree with Jim Garrison, there is not enough info for someone to debug your problem. – Wizard of Ogz May 06 '12 at 21:35