diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/persistence.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index 8a3c3fed7d..d492ac7f16 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -193,8 +193,12 @@ module ActiveRecord name = name.to_s raise ActiveRecordError, "#{name} is marked as readonly" if self.class.readonly_attributes.include?(name) raise ActiveRecordError, "can not update on a new record object" unless persisted? + + updated_count = self.class.update_all({ name => value }, self.class.primary_key => id) == 1 + raw_write_attribute(name, value) - self.class.update_all({ name => value }, self.class.primary_key => id) == 1 + + updated_count == 1 end # Updates the attributes of the model from the passed-in hash and saves the |