This is my first contribution to Rails and I've only been using Ruby for a few weeks or so, so please forgive me if my code does not follow any conventions.
I am trying to convert my company from C# to Ruby, but since we produce applications almost exclusively for the finance industry I thought the lack of support for SQL decimals would pretty much destroy any chances of that. So I've patched ActiveRecord so you can access decimal types in the database as BigDecimal classes in Ruby.
The CRUD process is the same except you now get BigDecimals back instead of Floats (the exception being that colums defined with no scale, eg decimal(5) are returned as Integers). There is no provision in the patch to override this and return Floats, seeing as I hope one day all adapters will return BigDecimals.
You can also use the type :decimal in migrations to add columns to your database. Specify options :precision and :scale instead of limit, eg
create_table :users do |table|
table.column :my_decimal, :decimal, :precision => 12, :scale => 4
end
will give you a colum numeric(12,4)
Omitting the scale will still give you a numeric field; it will only be converted to an Integer when you read the data back.
(I haven't actually tested this in practice, but the unit tests generate the correct SQL to add the columns)
The patch is against the stable branch, at revision 3901. Let me know if it's acceptable. The changes are restricted to the PostgreSQLAdapter class so they should not affect other databases. If I get time, I'd be willing to work on abstracting the decimal type to work with all adapters.