Skip to content

Commit

Permalink
Skip if the association was already loaded.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zachary Scott committed May 24, 2014
1 parent ade105b commit b13d260
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions activerecord/lib/active_record/associations/preloader.rb
Expand Up @@ -143,6 +143,7 @@ def preloaders_for_one(association, records, scope)
def grouped_records(association, records) def grouped_records(association, records)
h = {} h = {}
records.each do |record| records.each do |record|
next unless record
assoc = record.association(association) assoc = record.association(association)
klasses = h[assoc.reflection] ||= {} klasses = h[assoc.reflection] ||= {}
(klasses[assoc.klass] ||= []) << record (klasses[assoc.klass] ||= []) << record
Expand Down

0 comments on commit b13d260

Please sign in to comment.