184
185
186
187
188
189
190
191
192
193
194
195
196
197
|
# File 'lib/torque/postgresql/relation/inheritance.rb', line 184
def preload_associations(records)
super
return if expand_records_scoped_value.blank?
expand_records_scoped_value.each do |base_model, targets|
preloaded_association_names.each do |name|
reflection = model.reflect_on_association(name)
next if reflection.nil? || reflection.polymorphic? || !(reflection.klass <= base_model)
loaded = records.flat_map { |record| record.association(name).target }
PostgreSQL::Inheritance::Expander.new(reflection.klass, loaded.compact, targets).call
end
end
end
|