I\'m trying to calculate the average net price of a product. I have, in my Product model :total_sold and :total_net_revenue. Doing straight division in the method seems to a
Even if one of values are Float, result will be Float.
Also if you using Rails and your data stores in specific model, ActiveRecord has special methods and you don't need to calculate by yourself.
Model.average("field_with_data")
Also available minimum, maximum, count, sum methods.