views:

10

answers:

1

I have a model, called delivery:

property :id,           Serial
property :created_at,   DateTime
property :updated_at,   DateTime

property :price, BigDecimal,    :precision => 10, :scale => 2

Delivery has a price, which when viewed in SQLite is values such as 5.49, 6.95, 4.95

When displaying this information in the output (coded in haml), the values from delivery.price are displayed like 0.695E1 , 0.495E1 etc

Any idea why they are showing in this format, and how best to display them 'correctly.

All help is appreciated!

A: 

Conversion to string (BigDecimal#to_s) takes a format parameter:

>> n = BigDecimal.new('5.49')
=> #<BigDecimal:100502958,'0.549E1',18(18)>
>> n.to_s
=> "0.549E1"
>> n.to_s('F')
=> "5.49"
Andrew Vit
Thanks, that worked perfectly.
Neil