I am trying to get my console to print out a summation of all my Locations rate card pricing.
I am trying to complete this task through the console but getting a BigDecimal as the result. Stuck on how to convert this result into a legible string or integer.
Results:
Location.pluck(:rate_card).sum
=> "#<BigDecimal:7f7cf347edd0,'0.3091675E6',18(36)>"
In my Location 'index', to be able to see a dollar amount, I have this setup as:
<%= number_to_currency(location.rate_card, :precision => 2) %>
TIA
Location.each do |e|
puts e.rate_card.to_s.to_f.round(2)
end
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