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.11.3 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.11.2 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.11.1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.11 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.10 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.10.rc1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.9 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.9.rc2 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.9.rc1 lib/active_record/associations/preloader/collection_association.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activerecord-4.2.8/lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.8 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.8.rc1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.7.1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.7 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.16 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.16.rc1 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.7.rc1 lib/active_record/associations/preloader/collection_association.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.6/lib/active_record/associations/preloader/collection_association.rb
activerecord-4.1.15 lib/active_record/associations/preloader/collection_association.rb
activerecord-4.2.6 lib/active_record/associations/preloader/collection_association.rb