From 21c75e545a798b75d3ad1eaceea567e725ee655a Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Mon, 18 Feb 2008 04:49:56 +0000 Subject: Ensure nested preloading works when associations return nil. Closes #11145 [GMFlash] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8894 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/lib/active_record/association_preload.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib') diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb index 87b087bfea..9ef8ed15e8 100644 --- a/activerecord/lib/active_record/association_preload.rb +++ b/activerecord/lib/active_record/association_preload.rb @@ -21,7 +21,7 @@ module ActiveRecord preload_associations(records, parent, preload_options) reflection = reflections[parent] parents = records.map {|record| record.send(reflection.name)}.flatten - unless parents.empty? + unless parents.empty? || parents.first.nil? parents.first.class.preload_associations(parents, child) end end -- cgit v1.2.3