Flowdock
method

preload_one_association

Importance_0
v2.1.0 - Show latest stable - 0 notes - Class: ActiveRecord::AssociationPreload::ClassMethods
preload_one_association(records, association, preload_options={}) private

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/association_preload.rb, line 33
      def preload_one_association(records, association, preload_options={})
        class_to_reflection = {}
        # Not all records have the same class, so group then preload
        # group on the reflection itself so that if various subclass share the same association then we do not split them
        # unncessarily
        records.group_by {|record| class_to_reflection[record.class] ||= record.class.reflections[association]}.each do |reflection, records|
          raise ConfigurationError, "Association named '#{ association }' was not found; perhaps you misspelled it?" unless reflection
          send("preload_#{reflection.macro}_association", records, reflection, preload_options)
        end
      end
Register or log in to add new notes.