aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2006-06-25 17:49:24 +0000
committerNicholas Seckar <nseckar@gmail.com>2006-06-25 17:49:24 +0000
commitd9125093e8caaf112312d6e59052c3f20725fad2 (patch)
tree81e92033f131c4fb6cd8e4e1047473b7f4a932d5 /activerecord/lib/active_record/associations
parent99d268c8534ad398c6c60a4978ef94699cbb8ada (diff)
downloadrails-d9125093e8caaf112312d6e59052c3f20725fad2.tar.gz
rails-d9125093e8caaf112312d6e59052c3f20725fad2.tar.bz2
rails-d9125093e8caaf112312d6e59052c3f20725fad2.zip
Add AssociationCollection#sum since the method_missing invokation has been shadowed by Enumerable#sum. Closes #5500.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4493 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/association_collection.rb5
1 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb
index 61ad6ab7b6..ec7af7913d 100644
--- a/activerecord/lib/active_record/associations/association_collection.rb
+++ b/activerecord/lib/active_record/associations/association_collection.rb
@@ -42,6 +42,11 @@ module ActiveRecord
reset_target!
end
+ # Calculate sum using SQL, not Enumerable
+ def sum(*args, &block)
+ calculate(:sum, *args, &block)
+ end
+
# Remove +records+ from this association. Does not destroy +records+.
def delete(*records)
records = flatten_deeper(records)