aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-01-24 23:01:30 +0000
committerJon Leighton <j@jonathanleighton.com>2011-01-30 11:58:08 +0000
commit140b269fb7aee85e6da32da5305f771099d35af5 (patch)
tree07b367286f1f629aa489aac0233c2d45f78f17eb
parentca7785847eafaf687b10c7757dc034d08d1e6ba8 (diff)
downloadrails-140b269fb7aee85e6da32da5305f771099d35af5.tar.gz
rails-140b269fb7aee85e6da32da5305f771099d35af5.tar.bz2
rails-140b269fb7aee85e6da32da5305f771099d35af5.zip
Call sum on the scope directly, rather than relying on method_missing and calculate
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 7151f53fdb..7fd15e4bd6 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -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