instance method
write_attribute_with_dirty
Ruby on Rails 2.3.18
Since v2.2.3 Last seen in v2.3.18 PrivateAvailable in: v2.2.3 v2.3.18
Signature
write_attribute_with_dirty(attr, value)
Wrap write_attribute to remember original attribute value.
Parameters
-
attrreq -
valuereq
Source
# File activerecord/lib/active_record/dirty.rb, line 126
def write_attribute_with_dirty(attr, value)
attr = attr.to_s
# The attribute already has an unsaved change.
if changed_attributes.include?(attr)
old = changed_attributes[attr]
changed_attributes.delete(attr) unless field_changed?(attr, old, value)
else
old = clone_attribute_value(:read_attribute, attr)
changed_attributes[attr] = old if field_changed?(attr, old, value)
end
# Carry on.
write_attribute_without_dirty(attr, value)
end
Defined in activerecord/lib/active_record/dirty.rb line 126
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::Dirty