Why do my decimal value rows are values such as #> instead of just a regular decimal number?
I have a cost column and I get weird values. Is that ok? If so why?
That's just how Ruby prints out BigDecimal objects by default. Not sure why they chose such an ugly format, but hey - maybe some of the extra information can be useful.
Anyway, you should still be able to use them as you expect - it's just a bit of display weirdness. If you want to print a BigDecimal in a more normal format, call to_s
on it first, or use puts
, which calls to_s
for you.
Hope that helps!
Rails automatically casts the "row" decimal value into the Ruby object that it most resembles. In this case, a BigDecimal.
To print it out in a nice way, you can use "to_s" eg:
puts my_decimal.to_s
=> "3000000000000000000.0"
which should print it out nicer than the ugly class-named version you are seeing now.
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