Call sum on the scope directly, rather than relying on method_missing and calculate

This commit is contained in:
Jon Leighton
2011-01-24 23:01:30 +00:00
parent ca7785847e
commit 140b269fb7

View File

@@ -125,9 +125,9 @@ module ActiveRecord
# Calculate sum using SQL, not Enumerable
def sum(*args)
if block_given?
calculate(:sum, *args) { |*block_args| yield(*block_args) }
scoped.sum(*args) { |*block_args| yield(*block_args) }
else
calculate(:sum, *args)
scoped.sum(*args)
end
end