diff options
author | Jon Leighton <j@jonathanleighton.com> | 2011-01-24 23:01:30 +0000 |
---|---|---|
committer | Jon Leighton <j@jonathanleighton.com> | 2011-01-30 11:58:08 +0000 |
commit | 140b269fb7aee85e6da32da5305f771099d35af5 (patch) | |
tree | 07b367286f1f629aa489aac0233c2d45f78f17eb | |
parent | ca7785847eafaf687b10c7757dc034d08d1e6ba8 (diff) | |
download | rails-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.rb | 4 |
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 |