Reputation: 542
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?
Upvotes: 0
Views: 218
Reputation: 52357
I think you have some validation/callback preventing the correct value to be written to database. Double check validations/callbacks in Bill
model.
Upvotes: 1