I want to make sure I don't have rounding issues when it comes to storing prices for products in a rails app.
What mysql datatype should I use, and what does it map to in rails?
I want decimal with 10 places for precision.
Sounds you want the :decimal
column type. You can control the total number of digits and the number of decimal places with the :precision
and :scale
options:
add_column :mytable, :mycolumn, :decimal, :precision => 30, :scale => 10
A little more on data types in this documentation (no idea what the column
function is, though - probably internal!).
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With