What you had before you saved w/`previous_changes`
When you set values into the ActiveRecord object the previous values are still available with changes
, but when you save, however you save, those changes are wiped out. You can access what those values were before saving with previous_changes
.
> thing = Thing.create({color: 'blue', status: 'active'})
> thing.color = 'red'
> puts thing.changes
{"color" => ['blue', 'red']}
> puts thing.previous_changes
{}
> thing.save
> puts thing.changes
{}
> puts thing.previous_changes
{"color" => ['blue', 'red']}
Tweet