diff options
author | Angelo Capilleri <capilleri@yahoo.com> | 2013-01-08 22:44:38 +0100 |
---|---|---|
committer | Angelo Capilleri <capilleri@yahoo.com> | 2013-01-08 22:46:04 +0100 |
commit | 3543fdee7fc24eb2a9305a36eb093a2c726408b9 (patch) | |
tree | ef2f60fc469e9771e8d2aebe10f87238108c2720 /activerecord/lib | |
parent | e5d4367e191c55a61e4024aac1995edbfbf71090 (diff) | |
download | rails-3543fdee7fc24eb2a9305a36eb093a2c726408b9.tar.gz rails-3543fdee7fc24eb2a9305a36eb093a2c726408b9.tar.bz2 rails-3543fdee7fc24eb2a9305a36eb093a2c726408b9.zip |
improved different_target conditions
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/belongs_to_association.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/belongs_to_association.rb b/activerecord/lib/active_record/associations/belongs_to_association.rb index 75f72c1a46..532af3e83e 100644 --- a/activerecord/lib/active_record/associations/belongs_to_association.rb +++ b/activerecord/lib/active_record/associations/belongs_to_association.rb @@ -50,8 +50,11 @@ module ActiveRecord # Checks whether record is different to the current target, without loading it def different_target?(record) - record.nil? && owner[reflection.foreign_key] || - record && record.id != owner[reflection.foreign_key] + if record.nil? + owner[reflection.foreign_key] + else + record.id != owner[reflection.foreign_key] + end end def replace_keys(record) |