aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/association_preload.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2008-02-18 04:49:56 +0000
committerMichael Koziarski <michael@koziarski.com>2008-02-18 04:49:56 +0000
commit21c75e545a798b75d3ad1eaceea567e725ee655a (patch)
treefc50b85aa2e64d10e3ec9d48b7cfeaea9ea74914 /activerecord/lib/active_record/association_preload.rb
parentcae1d960d294e4e910895f4a25b6e5a59e91d492 (diff)
downloadrails-21c75e545a798b75d3ad1eaceea567e725ee655a.tar.gz
rails-21c75e545a798b75d3ad1eaceea567e725ee655a.tar.bz2
rails-21c75e545a798b75d3ad1eaceea567e725ee655a.zip
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
Diffstat (limited to 'activerecord/lib/active_record/association_preload.rb')
-rw-r--r--activerecord/lib/active_record/association_preload.rb2
1 files changed, 1 insertions, 1 deletions
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