hi Justin Firstly and kind of unrelated, for using money, you /really/ should use a decimal value (or an integer number of cents/pennies/whatever), instead of the imprecision of floating point arithmetic. People object when you accidentally add things to the bill through incorrect rounding.
Second ... have you auto_migrated! on Heroku? Or to ask another way: what's the column type underlying the :amount property? DataMapper is reasonably flexible in what columns it can persist a value to, and I suspect it might be a decimal property with scale 0 on heroku. Unfortunately auto_upgrade! does not (yet) change the types of already existing columns. Regards Jonathan On 13 January 2011 08:01, Justin Bozonier <[email protected]> wrote: > Hi guys! I LOVE DataMapper but this issue has me totally stumped. For > the below model if I set the :amount field to 42.42 (ie. not a whole > integer value), I get back 42.0 when I reload this data from the db. > > class UnpaidBill > include DataMapper::Resource > > property :id, Serial > property :description, String, :default => "" > property :amount, Float > property :date_due, Date > property :note, String, :default => "" > > belongs_to :pay_period > end > > Initially I was using Decimal and setting precision and scale but that > had this same issue as well. Am I doing something entirely stupid? > > This issue only exhibits itself in Heroku and not on my local dev > machine (even though as far as I can tell Heroku and my dev machine > both have the latest gems installed). > > Thank you in advance. > > Justin Bozonier > > -- > You received this message because you are subscribed to the Google Groups > "DataMapper" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/datamapper?hl=en. > > -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.
