Sha256: 3f255b3488dae503e45455f1b5332f0c50441b78a6093ef9286836618ca510ae

Contents?: true

Size: 640 Bytes

Versions: 95

Compression:

Stored size: 640 Bytes

Contents

module ActiveRecord
  module Associations
    class Preloader
      class CollectionAssociation < Association #:nodoc:

        private

        def build_scope
          super.order(preload_scope.values[:order] || reflection_scope.values[:order])
        end

        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

Version data entries

95 entries across 91 versions & 8 rubygems

Version Path
activerecord-4.2.0.beta1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.6.rc1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.5 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.4 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.3 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.2 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.2.rc3 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.2.rc2 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.2.rc1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.0 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.0.rc2 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.0.rc1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.0.beta2 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.0.beta1 lib/active_record/associations/preloader/collection_association.rb