If you want to track whether your active record objects have been modified or not. It becomes a lot easier with the dirty object functionality. It’s pretty straightforward and clean.
You can also query to object directly for its list of all changed attributes.
Once you save a dirty object it clears out its changed state tracking and is once again considered unchanged.
If you’re going to be modifying an attribute outside of the attr= writer, you can use attr_name_will_change! to tell the object to be aware of the change: