0
[1] BigDecimal
BigDecimal < Numeric
[2] account.outstanding_balance = BigDecimal.new(0.3, 2)
0.3
[3] account.outstanding_balance
0

I cannot figure out why I am unable to assign account.outstanding_balance a decimal value of .3.

This is a rails app using mysql. The column outstanding_balance is decimal type.

Rails v3.2

Eric Francis
  • 23,039
  • 31
  • 88
  • 122

1 Answers1

0
t.decimal  "outstanding_balance", :precision => 10, :scale => 0

Scale Defines the scale for the decimal fields, representing the number of digits after the decimal point.

So this was lame. A migration with:

create_table :account do |t|
  t.decimal :outstanding_balance
end

Will automatically populate schema.rb with the above code.

Eric Francis
  • 23,039
  • 31
  • 88
  • 122