diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-14 15:58:59 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-14 15:58:59 -0800 |
commit | a0a69b045adeced5754251706a0401b75e7e03ec (patch) | |
tree | d8e8b208592b860af5ac139d07b1fdfcdc6de9d5 /activerecord | |
parent | c326969745c38aaca552aebf240af644440afab3 (diff) | |
download | rails-a0a69b045adeced5754251706a0401b75e7e03ec.tar.gz rails-a0a69b045adeced5754251706a0401b75e7e03ec.tar.bz2 rails-a0a69b045adeced5754251706a0401b75e7e03ec.zip |
loaded? will not raise an AR::RecordNotFound exception, so move the rescue inside the conditional
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/association_collection.rb | 8 |
1 files 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 |