Ruby thinks (19.99 * 100).to_i = 1998
Thursday, March 26th, 2009 By: Daniel>> (19.99 * 100).to_i => 1998 >> (9.99 * 100).to_i => 999
Someone please tell me what’s up with that!
In the meantime:
>> (19.99 * 100).to_s.to_i => 1999
>> (19.99 * 100).to_i => 1998 >> (9.99 * 100).to_i => 999
Someone please tell me what’s up with that!
In the meantime:
>> (19.99 * 100).to_s.to_i => 1999
We ran into a few little gotchas with ActiveRecord’s find method when upgrading from Rails 2.1.1 to 2.2.2. The solutions are pretty trivial, so the main lesson here is to test your code so things like this get caught by your test suite and not the client.