aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/preloader/collection_association.rb
blob: 24b8e010292c45ba5a972a6b061731ff9ed681f4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
module ActiveRecord
  module Associations
    class Preloader
      class CollectionAssociation < Association #:nodoc:
        private

          def preload(preloader)
            associated_records_by_owner(preloader).each do |owner, records|
              association = owner.association(reflection.name)
              association.loaded!
              association.target.concat(records)
              records.each { |record| association.set_inverse_instance(record) }
            end
          end
      end
    end
  end
end