Extract all attribute changed work to its own method

This will make easier to hook on this feature to customize the behavior
上级 b8302bcf
......@@ -43,6 +43,13 @@ def reload(*)
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 @@ def write_attribute(attr, value)
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(*)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册