From 75e29e871e925cb7485cdbc283594d3d97871703 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 14 Jan 2011 16:57:14 -0800 Subject: only find_target can raise the exception, so isolate the rescue around that call --- .../active_record/associations/association_collection.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'activerecord/lib/active_record/associations/association_collection.rb') 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 -- cgit v1.2.3