diff options
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index 864d84d71a..1254d68e9a 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -351,15 +351,19 @@ module ActiveRecord def load_target if !@owner.new_record? || foreign_key_present? unless loaded? + targets = [] + begin - if @target.any? - @target = merge_target_lists(find_target, @target) - else - @target = find_target - end + targets = find_target rescue ActiveRecord::RecordNotFound reset end + + if @target.any? + @target = merge_target_lists(targets, @target) + else + @target = targets + end end end |