ActiveRecord’s sum or Rails’ Enumerable’s sum?
product.inventory_transactions.sum(&:amount) # ArgumentError: wrong number of arguments…
Why? Because model.relationship returns a modified version of the Array class. The object returned acts very much like (if not identical to) calling Model.find, and accepts most (if not all) of find’s options.
So note that if you are calling model.relationship.sum, you either specify the attribute you’re interested in:
product.inventory_transactions.sum(:amount)
Or, if, [...]


