Ruby on Rails and longints (Bignum)
August 31st, 2007
I just spent an hour or so fiddling around with Rails and MySql trying to debug an issue with large numbers being sent from the client.
The long and short (yuk yuk) of it is that Rails seems to cast values defined in the migration as :integer into Fixnum rather than checking to see if it should make them a Bignum instead. Boo urns.
There’s probably a more robust way to solve this using attribute_before_type_cast and facade columns, but I don’t need that robustness, since I’m not doing any math on integer (it’s just a unique id sent by the client). Instead, I defined them it as a :string and all is well.
Just a note so that someone else can hopefully see this issue before spending an hour googling!





Leave a Reply