diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-14 17:08:27 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-01-14 17:08:27 -0800 |
commit | 0aef847927ed2f9c3e3dca92207d9a62baa01b1a (patch) | |
tree | 1f81ff08660f104865959eb8a32c4ee0f4e1ac78 /activerecord | |
parent | b8ed2d5ddff3db22430de983ba072f57b8aa3c00 (diff) | |
download | rails-0aef847927ed2f9c3e3dca92207d9a62baa01b1a.tar.gz rails-0aef847927ed2f9c3e3dca92207d9a62baa01b1a.tar.bz2 rails-0aef847927ed2f9c3e3dca92207d9a62baa01b1a.zip |
push !loaded? conditional up
Diffstat (limited to 'activerecord')
-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 |