From a0a69b045adeced5754251706a0401b75e7e03ec Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 14 Jan 2011 15:58:59 -0800 Subject: loaded? will not raise an AR::RecordNotFound exception, so move the rescue inside the conditional --- .../lib/active_record/associations/association_collection.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index e65ef2b768..bf40446871 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -350,8 +350,8 @@ module ActiveRecord def load_target if !@owner.new_record? || foreign_key_present? - begin - unless loaded? + unless loaded? + begin if @target.is_a?(Array) && @target.any? @target = find_target.map do |f| i = @target.index(f) @@ -371,9 +371,9 @@ module ActiveRecord else @target = find_target end + rescue ActiveRecord::RecordNotFound + reset end - rescue ActiveRecord::RecordNotFound - reset end end -- cgit v1.2.3