mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Association preloading no longer stops if it hits a nil object [#1630 state:resolved]
Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com>
This commit is contained in:
committed by
Frederick Cheung
parent
c9d4335418
commit
eb457ceee1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user