instance method saved_change_to_attribute

Ruby on Rails 5.2.8.1

Since v5.2.8.1

Available in: v5.2.8.1 v6.0.6 v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

saved_change_to_attribute(attr_name)

Returns the change to an attribute during the last save. If the attribute was changed, the result will be an array containing the original value and the saved value.

Behaves similarly to attribute_change. This method is useful in after callbacks, to see the change in an attribute that just occurred

This method can be invoked as saved_change_to_name in instead of saved_change_to_attribute("name")

Parameters

attr_name req
Source
# File activerecord/lib/active_record/attribute_methods/dirty.rb, line 65
      def saved_change_to_attribute(attr_name)
        mutations_before_last_save.change_to_attribute(attr_name)
      end

Defined in activerecord/lib/active_record/attribute_methods/dirty.rb line 65 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::AttributeMethods::Dirty

Type at least 2 characters to search.

↑↓ navigate · open · esc close