From edd94cee9af1688dd036fc58fd405adb30a5e0da Mon Sep 17 00:00:00 2001 From: Jon Leighton Date: Fri, 9 Nov 2012 12:09:37 +0000 Subject: Delegate all calculations to the scope. So that the scope may be a NullRelation and return a result without executing a query. Fixes #7928 --- activerecord/lib/active_record/null_relation.rb | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'activerecord/lib/active_record/null_relation.rb') diff --git a/activerecord/lib/active_record/null_relation.rb b/activerecord/lib/active_record/null_relation.rb index f8f7a6c976..711fc8b883 100644 --- a/activerecord/lib/active_record/null_relation.rb +++ b/activerecord/lib/active_record/null_relation.rb @@ -50,6 +50,10 @@ module ActiveRecord 0 end + def sum(*) + 0 + end + def calculate(_operation, _column_name, _options = {}) nil end -- cgit v1.2.3