I have a form with an input(price
) that a user fills with values like: 12,50
or 110,90
(French prices).
So in the controller I do : @quote = current_user.company.quotes.build!(params[:quote])
The problem is that rails behaives with the decimals in the US
way. So it saves the quote with the price 12.00
or 111.90
So how do I tell rails to actually consider the european version of decimals?
Thanks.
UPDATE
The solution is to add this method to the Quote
model.
def price=(data) write_attribute(:price, data.to_s.gsub(',', '.')) end
This will replace ,
with .
. Thanks Olivier for the hint.