Skip to content

Instantly share code, notes, and snippets.

Currency model migration:
create_table :currencies do |t|
t.decimal :value, :precision => 12, :scale => 2
t.timestamps
end
Environment:
config.gem "delocalize"
>> c = Currency.new
=> #<Currency id: nil, value: nil, created_at: nil, updated_at: nil>
>> c.value = "100"
=> "100"
>> c.save
=> true
>> c.reload
=> #<Currency id: 2, value: #<BigDecimal:3b73164,'0.1E3',4(8)>, created_at: "200
9-12-24 19:59:05", updated_at: "2009-12-24 19:59:05">
>> c.value = "100,01"
>> c.value = "100,01"
=> "100,01"
>> c.changes
=> {}
>> c.value = "100,01"
=> "100,01"
>> c.changes
=> {"value"=>[#<BigDecimal:3aff2a0,'0.10001E3',8(12)>, #<BigDecimal:3af9d00,'0.1
0001E3',8(12)>]}