activerecord-precounter 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/lib/active_record/precounter.rb +3 -1
- data/lib/active_record/precounter/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa7ed8a641545585e1fcf838262efb66633387a173d65614d9ed7fe4100f2018
|
4
|
+
data.tar.gz: 2362e9a30228774378634e21f89c26f3cd21dd3051c9e56ba1bc2412e51e06fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3f7709814cfba9081356cb625c2350ad175384a7d688b439442c565193d315849480ad33b90e04672fa3fa9ebe0ff1a2af194b2c3d5d8853b050096a282cc0d4
|
7
|
+
data.tar.gz: 21366e80cab47df357670be5febdbbb1bb62bcea232bce497c5295c7adeed52929a59d41ede31d8919b477e2849b073f1a6168a118d18439f3af6d75141bc090
|
data/.gitignore
CHANGED
@@ -27,7 +27,9 @@ module ActiveRecord
|
|
27
27
|
end
|
28
28
|
|
29
29
|
count_by_id = if reflection.has_scope?
|
30
|
-
|
30
|
+
# ActiveRecord 5.0 unscopes #scope_for argument, so adding #where outside that:
|
31
|
+
# https://github.com/rails/rails/blob/v5.0.7/activerecord/lib/active_record/reflection.rb#L314-L316
|
32
|
+
reflection.scope_for(reflection.klass.unscoped).where(reflection.inverse_of.name => records.map(&:id)).group(
|
31
33
|
reflection.inverse_of.foreign_key
|
32
34
|
).count
|
33
35
|
else
|