aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-07-12 00:04:01 +0100
committerJon Leighton <j@jonathanleighton.com>2011-07-12 00:14:45 +0100
commit1712d90050bd4b32a9ee93548b5eef05a69491f7 (patch)
treecf76c0d1847f96d8f71c30f10c741d46dbe6f4b1 /activerecord/lib/active_record/associations
parent5c8be9eb864886d7ba9abba0d59786614cca2a5a (diff)
downloadrails-1712d90050bd4b32a9ee93548b5eef05a69491f7.tar.gz
rails-1712d90050bd4b32a9ee93548b5eef05a69491f7.tar.bz2
rails-1712d90050bd4b32a9ee93548b5eef05a69491f7.zip
Fix exception if old and new targets are both nil. Fixes #1471.
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/belongs_to_association.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/belongs_to_association.rb b/activerecord/lib/active_record/associations/belongs_to_association.rb
index c263edd2c6..adb6af7165 100644
--- a/activerecord/lib/active_record/associations/belongs_to_association.rb
+++ b/activerecord/lib/active_record/associations/belongs_to_association.rb
@@ -37,7 +37,7 @@ 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.id != owner[reflection.foreign_key]
+ record && record.id != owner[reflection.foreign_key]
end
def replace_keys(record)