Im using Ruby 2.4.1 with rails 5.0.2
Here is my code:
total_price = 600.0
o = client.bills.new(client_id: client, total_price: total_price.to_f)
#<Bill id: nil, client_id: 21, created_at: nil, updated_at: nil, total_price: 0.6e3, bill_id: nil, discount_price: nil>
o.save
it will save as 0.00 instead of 600.0 or 0.6e3 in my PostgreSQL. Oh, im using Numeric(8,2) as its datatypes which is decimal, :precision => 8, :scale => 2
My migration:
add_column :bills, :total_price, :decimal, :precision => 8, :scale => 2
Any clues?
total_price: 0.6e3is not zero.o.update_column(total_price: 123.45). If that works it means you have some validation or something else preventing the correct number to be saved