aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorPivotal Labs <opensource@pivotallabs.com>2008-12-24 14:57:09 -0800
committerFrederick Cheung <frederick.cheung@gmail.com>2008-12-26 18:25:50 +0000
commiteb457ceee13779ade67e1bdebd2919d476148277 (patch)
treeddaa96980a5b48f4e3d940c4545a2ab3a65a1a2d /activerecord/lib
parentc9d4335418823500548ad8fbc86af7c910b7644b (diff)
downloadrails-eb457ceee13779ade67e1bdebd2919d476148277.tar.gz
rails-eb457ceee13779ade67e1bdebd2919d476148277.tar.bz2
rails-eb457ceee13779ade67e1bdebd2919d476148277.zip
Association preloading no longer stops if it hits a nil object [#1630 state:resolved]
Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com>
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/association_preload.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/association_preload.rb b/activerecord/lib/active_record/association_preload.rb
index 7b1b2d9ad9..0bcf50c167 100644
--- a/activerecord/lib/active_record/association_preload.rb
+++ b/activerecord/lib/active_record/association_preload.rb
@@ -94,8 +94,8 @@ module ActiveRecord
raise "parent must be an association name" unless parent.is_a?(String) || parent.is_a?(Symbol)
preload_associations(records, parent, preload_options)
reflection = reflections[parent]
- parents = records.map {|record| record.send(reflection.name)}.flatten
- unless parents.empty? || parents.first.nil?
+ parents = records.map {|record| record.send(reflection.name)}.flatten.compact
+ unless parents.empty?
parents.first.class.preload_associations(parents, child)
end
end