I've never come across this before. I'm working with a table attribute whos value is a string, not float/int.
Model.first.amount => "58.00"
Model.all.sum(&:amount) => # total value
Model.all.sum(&:amount.to_i) # undefined method `to_i' for :amount:Symbol
Processing database with Ruby is super memory ineffective!
Model .pluck(:amount) # will fire sql .sum(&:to_f) # convert to float, operating on resulting Array, not AR and sum
But the most effective way to process database data is SQL of course:
Model.sum("CAST(COALESCE(amount, '0') AS FLOAT)")
coalescewill replace null values with
sumall values casted to