I have the following situation: If the name attribute of my student object changes, I want to keep the old value and save it to another table.
So, If I have a student object with the name attribute ‘John 1’, after a student.update_attributes(:name => ‘John 2’) I want to be able to capture the old name value ‘John 1’ in a before_update callback hook, for instance. What’s the best way to do that ? Thanks in advance.
In the
before_updatehook, you can access special_wasmethods to get the previous value of each field