diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-01-20 21:57:47 -0200 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-01-21 12:45:06 -0200 |
commit | a4cc88d0851343ac16e2294c06c5a4101189c410 (patch) | |
tree | 9ead9996df884d5c560387d3e4da5d817e686828 /activerecord | |
parent | b8302bcfdaec2a9e7658262d6feeb535c572922d (diff) | |
download | rails-a4cc88d0851343ac16e2294c06c5a4101189c410.tar.gz rails-a4cc88d0851343ac16e2294c06c5a4101189c410.tar.bz2 rails-a4cc88d0851343ac16e2294c06c5a4101189c410.zip |
Extract all attribute changed work to its own method
This will make easier to hook on this feature to customize the behavior
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/attribute_methods/dirty.rb | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/attribute_methods/dirty.rb b/activerecord/lib/active_record/attribute_methods/dirty.rb index 19e81abba5..f7065d183f 100644 --- a/activerecord/lib/active_record/attribute_methods/dirty.rb +++ b/activerecord/lib/active_record/attribute_methods/dirty.rb @@ -43,6 +43,13 @@ module ActiveRecord def write_attribute(attr, value) attr = attr.to_s + save_changed_attribute(attr, value) + + # Carry on. + super(attr, value) + end + + def save_changed_attribute(attr, value) # The attribute already has an unsaved change. if attribute_changed?(attr) old = changed_attributes[attr] @@ -51,9 +58,6 @@ module ActiveRecord old = clone_attribute_value(:read_attribute, attr) changed_attributes[attr] = old if _field_changed?(attr, old, value) end - - # Carry on. - super(attr, value) end def update_record(*) |