mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Call sum on the scope directly, rather than relying on method_missing and calculate
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user