# In after\_update, possible to see previous value of record?

**URL:** <https://www.ruby-forum.com/t/in-after-update-possible-to-see-previous-value-of-record/88356>\
**Category:** Rails\
**Created:** [March 9, 2007, 11:36pm UTC](https://www.ruby-forum.com/t/in-after-update-possible-to-see-previous-value-of-record/88356 "2007-03-09T23:36:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan\_kuwachi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dfb087/32.png) [@dan\_kuwachi](https://www.ruby-forum.com/u/dan_kuwachi)\
**Post date:** [March 9, 2007, 11:36pm UTC](https://www.ruby-forum.com/t/in-after-update-possible-to-see-previous-value-of-record/88356/1 "2007-03-09T23:36:25Z")

</div>

I have this situation where in an after\_update, I would like to know  
the previous value of the record instead of simply being notified the  
record has been updated.

For example let’s say I had a table called ‘foo’ which had a field  
‘new\_flag’. I want to know when the ‘new\_flag’ field changes from 0 –

> 1 in an after\_update so I can do some business logic in the  
> after\_update. My problem is in the after\_update I don’t know how to  
> detect if that particular field got updated.

Is there some api call I can use to access the old object?

thanks!  
-dan

---

<div class="post-metadata">

**Author:** ![dan\_kuwachi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/dfb087/32.png) [@dan\_kuwachi](https://www.ruby-forum.com/u/dan_kuwachi)\
**Post date:** [March 10, 2007, 3:05am UTC](https://www.ruby-forum.com/t/in-after-update-possible-to-see-previous-value-of-record/88356/2 "2007-03-10T03:05:43Z")

</div>

Use the acts\_as\_versioned plugin  
[Peak Obsession](http://wiki.rubyonrails.com/rails/pages/ActsAsVersioned).  
You can use the API that will allow you to call the previous version  
object and access its values.
