diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-21 20:44:21 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-09-21 20:44:21 -0700 |
commit | 8186c5736bef4597dd8c1f94bd6343eae7bda70e (patch) | |
tree | 969f78a12748ccd0371fd6a3ae8e150102da8420 /activerecord | |
parent | 723adecab9439775452978e82be421ea2e257133 (diff) | |
download | rails-8186c5736bef4597dd8c1f94bd6343eae7bda70e.tar.gz rails-8186c5736bef4597dd8c1f94bd6343eae7bda70e.tar.bz2 rails-8186c5736bef4597dd8c1f94bd6343eae7bda70e.zip |
dry up some conditionals
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb index 3b02a30915..4fcc754a23 100644 --- a/activerecord/lib/active_record/associations.rb +++ b/activerecord/lib/active_record/associations.rb @@ -1976,22 +1976,23 @@ module ActiveRecord end def construct_association(record, join, row) + return if record.id.to_s != join.parent.record_id(row).to_s + case join.reflection.macro when :has_many, :has_and_belongs_to_many collection = record.send(join.reflection.name) collection.loaded - return nil if record.id.to_s != join.parent.record_id(row).to_s or row[join.aliased_primary_key].nil? + return if row[join.aliased_primary_key].nil? association = join.instantiate(row) collection.target.push(association) collection.__send__(:set_inverse_instance, association, record) when :has_one - return if record.id.to_s != join.parent.record_id(row).to_s return if record.instance_variable_defined?("@#{join.reflection.name}") association = join.instantiate(row) unless row[join.aliased_primary_key].nil? set_target_and_inverse(join, association, record) when :belongs_to - return if record.id.to_s != join.parent.record_id(row).to_s or row[join.aliased_primary_key].nil? + return if row[join.aliased_primary_key].nil? association = join.instantiate(row) set_target_and_inverse(join, association, record) else |