From 6c4245debf0123a4a65de527626c5a8244f4e432 Mon Sep 17 00:00:00 2001 From: Kai Schlichting Date: Wed, 9 Dec 2015 16:56:24 +0100 Subject: [PATCH] move logic for determining which attributes should be saved into own method so that it can be overwritten also read https://github.com/rails/rails/issues/8328#issuecomment-31665046 --- activerecord/lib/active_record/attribute_methods/dirty.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/attribute_methods/dirty.rb b/activerecord/lib/active_record/attribute_methods/dirty.rb index 9cd8954496262..348a4451d3fde 100644 --- a/activerecord/lib/active_record/attribute_methods/dirty.rb +++ b/activerecord/lib/active_record/attribute_methods/dirty.rb @@ -71,12 +71,16 @@ def update(*) if partial_updates? # Serialized attributes should always be written in case they've been # changed in place. - super(changed | (attributes.keys & self.class.serialized_attributes.keys)) + super(keys_for_partial_write) else super end end + def keys_for_partial_write + changed | (attributes.keys & self.class.serialized_attributes.keys) + end + def _field_changed?(attr, old, value) if column = column_for_attribute(attr) if column.number? && (changes_from_nil_to_empty_string?(column, old, value) ||