diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-28 16:01:12 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-28 16:01:12 -0700 |
commit | 74c2961bd864f633c79c03e62c2cb142642201c5 (patch) | |
tree | 442b1f37ab6aa110d3d2a21a14c65b3a8dc9b327 /activerecord/lib/active_record/relation | |
parent | 9e42cf019f2417473e7dcbfcb885709fa2709f89 (diff) | |
download | rails-74c2961bd864f633c79c03e62c2cb142642201c5.tar.gz rails-74c2961bd864f633c79c03e62c2cb142642201c5.tar.bz2 rails-74c2961bd864f633c79c03e62c2cb142642201c5.zip |
Don't error when grouped calculations return 0 records
Fixes #18717
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r-- | activerecord/lib/active_record/relation/calculations.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 83745bc169..c3c4d7f1ce 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -304,7 +304,7 @@ module ActiveRecord if association key_ids = calculated_data.collect { |row| row[group_aliases.first] } - key_records = association.klass.base_class.find(key_ids) + key_records = association.klass.base_class.where(association.klass.base_class.primary_key => key_ids) key_records = Hash[key_records.map { |r| [r.id, r] }] end |