Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #9640: fix_dont_attempt_to_preload_when_association_returns_nil.diff

File fix_dont_attempt_to_preload_when_association_returns_nil.diff, 0.7 kB (added by GMFlash, 3 months ago)
  • activerecord/lib/active_record/association_preload.rb

    old new  
    2121            preload_associations(records, parent, preload_options) 
    2222            reflection = reflections[parent] 
    2323            parents = records.map {|record| record.send(reflection.name)}.flatten 
    24             unless parents.empty? 
     24            unless parents.empty? || parents.first.nil? 
    2525              parents.first.class.preload_associations(parents, child) 
    2626            end 
    2727          end