decimal(x,y) columns in Rails 1.2 are mapped to BigDecimal object.
They works well, but it could be better.
For example, one column:
price decimal(5,2)
for an "articles" table is mapped to a BigDecimal object, but that object doesn't "remember" the corresponding column's :scale.
Therefore,
article = Articles.find(1)
article.price # this object is a BigDecimal one, but it doesn't knows how many fractional digits must contain
So "article.price.to_s" will not "render" the correct fractional digits based of the column's scale.
For example, if we save the 5.20 value into the column, then the expression
"article.price.to_s" will return "5.2".
In that way, if we save the 5 value, the expression "article.price.to_s" will return "5.0".
If the BigDecimal object could "remember" how many decimals it must to show, then the to_s method could always give you more appropriate results. In the case of 5.20, to_s will returns "5.20"; in the case of 5, to_s will returns "5.00". In the same way, if the column were decimal(5), when you save 5.20 or 5 values, to_s will always returns "5".
The patch I developed tries to solves the problem. With this patch, a BigDecimal object have a scale attribute, so the to_s method can know how to print the decimal correctly.
The patch touches files from ActiveRecord and ActiveSupport. The ActiveRecord part puts the scale into the BigDecimal object, and the ActiveSupport part prints the BigDecimal object according to the scale within in.