method

load_records

Importance_0
v7.0.0 - Show latest stable - 0 notes - Class: Association
load_records(raw_records = nil) public

No documentation

This method has no description. You can help the Ruby on Rails community by adding new notes.

Hide source
# File activerecord/lib/active_record/associations/preloader/association.rb, line 180
        def load_records(raw_records = nil)
          # owners can be duplicated when a relation has a collection association join
          # #compare_by_identity makes such owners different hash keys
          @records_by_owner = {}.compare_by_identity
          raw_records ||= loader_query.records_for([self])

          @preloaded_records = raw_records.select do |record|
            assignments = false

            owners_by_key[convert_key(record[association_key_name])]&.each do |owner|
              entries = (@records_by_owner[owner] ||= [])

              if reflection.collection? || entries.empty?
                entries << record
                assignments = true
              end
            end

            assignments
          end
        end
Register or log in to add new notes.