I have in my database a column value
with precision 7 and 2 type big decimal.
In my form I use the simple form and I also use the Mask, ie field for value entry would look like this:
70,567.54
However, at the time of saving, the controller receives this as a string and automatically converts, and everything after the first point is lost, getting only 70.0.
I tried to use gsub
to remove the "." and convert the "," to point and let it turn into converting to big decimal, but the rails is not letting the hash, I tried to use gem Money
, but it did not seem very useful (or I did not quite understand how use it, it only gives error saying that the value is not a number, of course comes string and I'm not able to treat). Maybe I should change the field type in the simple form? But then the mask would not appear.
Does anyone know how I could display the mask and still save the value as the user typed it in the field (I even thought about using it as a string, but it would take a lot of work later to do record calculations, sum, ).