File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,11 @@ def jit_preload(associations)
15
15
# It is possible that the records array has multiple different classes (think single table inheritance).
16
16
# Thus, it is possible that some of the records don't have an association.
17
17
records_with_association = records . reject { |r | r . class . reflect_on_association ( associations ) . nil? }
18
- self . class . new ( records : records_with_association , associations : associations ) . call
18
+
19
+ # Some of the records may already have the association loaded and we should not load them again
20
+ records_requiring_loading = records_with_association . select { |r | !r . association ( associations ) . loaded? }
21
+
22
+ self . class . new ( records : records_requiring_loading , associations : associations ) . call
19
23
end
20
24
21
25
# We do not want the jit_preloader to be dumpable
You can’t perform that action at this time.
0 commit comments