[Rails] BigDecimal column type?

Jeff Cohen cohen.jeff at gmail.com
Sat Apr 1 01:54:40 GMT 2006


I was hoping 1.1 would provide a way to map SQL "decimal" column types 
to BigDecimal values, since BigDecimal is part of the Ruby standard api 
as of 1.8.

But I don't see any support for that in the migration documentation, and 
when I try to let Active Record do the mapping for me, it seems to 
coerce the column into a Float (as the AwdwR book says).

Is it really there in 1.1 but I just don't know what to do to tap into 
it?  Or is it still not part of ActiveRecord yet?

I've heard about Tobias' "Money" plug-in but I'm not sure I want to go 
that route unless I have to.

Storing money values should be very common - any shopping-cart style web 
app will need to - but using floats can give rounding errors that can be 
hard to spot (unlike the decimal type).

Any ideas?  Maybe I'm missing something obvious?

Thanks!
Jeff

-- 
Posted via http://www.ruby-forum.com/.


More information about the Rails mailing list