diff options
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/associations/association_collection.rb b/activerecord/lib/active_record/associations/association_collection.rb index bd77aa30c1..b75e02c66b 100644 --- a/activerecord/lib/active_record/associations/association_collection.rb +++ b/activerecord/lib/active_record/associations/association_collection.rb @@ -349,18 +349,16 @@ module ActiveRecord end def load_target - if !@owner.new_record? || foreign_key_present? - unless loaded? - targets = [] - - begin - targets = find_target - rescue ActiveRecord::RecordNotFound - reset - end + if (!@owner.new_record? || foreign_key_present?) && !loaded? + targets = [] - @target = merge_target_lists(targets, @target) + begin + targets = find_target + rescue ActiveRecord::RecordNotFound + reset end + + @target = merge_target_lists(targets, @target) end loaded |