Sha256: eca8c01567ffd7828922783ab37d2414f62884ceba1793f2ae807c47e0253fb8

Contents?: true

Size: 618 Bytes

Versions: 30

Compression:

Stored size: 618 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
          associated_records_by_owner.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

30 entries across 30 versions & 2 rubygems

Version Path
activerecord-4.0.13 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.13.rc1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.11.1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.12 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.11 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.10 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.10.rc2 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.10.rc1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.9 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.8 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.7 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.6 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.6.rc3 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.6.rc2 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.6.rc1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.5 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.4 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.4.rc1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.3 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.0.2 lib/active_record/associations/preloader/collection_association.rb