diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-01-08 14:32:51 -0800 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2013-01-08 14:32:51 -0800 |
commit | d106925059cb76258ed8d5a539a7c266800a6b11 (patch) | |
tree | 96faa61e2849044a2d6a845ce0a44d3ae1add3d9 /activerecord/lib | |
parent | b28d6e2c76987011a4e7d67b91601ca518b05ec1 (diff) | |
parent | 3543fdee7fc24eb2a9305a36eb093a2c726408b9 (diff) | |
download | rails-d106925059cb76258ed8d5a539a7c266800a6b11.tar.gz rails-d106925059cb76258ed8d5a539a7c266800a6b11.tar.bz2 rails-d106925059cb76258ed8d5a539a7c266800a6b11.zip |
Merge pull request #8826 from acapilleri/different_target
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) |