From 168c0c171e1840211a57b8b7771e5c028cd79dc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Wed, 17 Sep 2014 16:26:49 -0300 Subject: [PATCH] Use has_attribute? --- activerecord/lib/active_record/autosave_association.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/autosave_association.rb b/activerecord/lib/active_record/autosave_association.rb index 2a5dd758a3..c384e8c413 100644 --- a/activerecord/lib/active_record/autosave_association.rb +++ b/activerecord/lib/active_record/autosave_association.rb @@ -404,7 +404,7 @@ module ActiveRecord # If the record is new or it has changed, returns true. def record_changed?(reflection, record, key) record.new_record? || - (record.attributes.keys.include?(reflection.foreign_key) && record[reflection.foreign_key] != key) || + (record.has_attribute?(reflection.foreign_key) && record[reflection.foreign_key] != key) || record.attribute_changed?(reflection.foreign_key) end