In my Rails 6 app I have a sales database with a value column. Since this is a 2 decimal number I changed the type to
change_column :sales, :value, :decimal, precision: 10, scale: 2
This app has an API where I render a sales object to json. When I read this API with my angular object and do:
console.log(typeof this.sale.id)
I get string
. And when I log the value I get:
value: "40.0"
Why does this happen? Before, when the columns was simples numeric this did not happen.
I know that I can convert the variable in JS to a float but I would like to know the reason and avoid converting the variable type.