Permalink
Browse files

improved different_target conditions

  • Loading branch information...
1 parent e5d4367 commit 3543fdee7fc24eb2a9305a36eb093a2c726408b9 @acapilleri acapilleri committed Jan 8, 2013
Showing with 5 additions and 2 deletions.
  1. +5 −2 activerecord/lib/active_record/associations/belongs_to_association.rb
View
7 activerecord/lib/active_record/associations/belongs_to_association.rb
@@ -50,8 +50,11 @@ def update_counters(record)
# 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)

0 comments on commit 3543fde

Please sign in to comment.