# Model and Attribute original Value

**URL:** <https://www.ruby-forum.com/t/model-and-attribute-original-value/126555>\
**Category:** Rails\
**Created:** [January 19, 2008, 2:31pm UTC](https://www.ruby-forum.com/t/model-and-attribute-original-value/126555 "2008-01-19T14:31:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nigel.bris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@nigel.bris](https://www.ruby-forum.com/u/nigel.bris)\
**Post date:** [January 19, 2008, 2:31pm UTC](https://www.ruby-forum.com/t/model-and-attribute-original-value/126555/1 "2008-01-19T14:31:27Z")

</div>

Hi Everyone,

Is there a way to when you find a record to keep the original value of  
the attributes. This would allow to see if an attribute has changed at  
save time and then do something. I am sure there is an cool way in  
rails to do this!

Thanks…

---

<div class="post-metadata">

**Author:** ![nigel.bris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@nigel.bris](https://www.ruby-forum.com/u/nigel.bris)\
**Post date:** [January 21, 2008, 10:04pm UTC](https://www.ruby-forum.com/t/model-and-attribute-original-value/126555/2 "2008-01-21T22:04:32Z")

</div>

On Jan 19, 2008 11:30 PM, nigel.bris [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi Everyone,
> 
> Is there a way to when you find a record to keep the original value of  
> the attributes. This would allow to see if an attribute has changed at  
> save time and then do something. I am sure there is an cool way in  
> rails to do this!

You can store it in the #after\_find hook:

class Thing \< ActiveRecord::Base  
def after\_find  
@original\_name = name  
end  
end

---

<div class="post-metadata">

**Author:** ![nigel.bris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@nigel.bris](https://www.ruby-forum.com/u/nigel.bris)\
**Post date:** [January 21, 2008, 11:51pm UTC](https://www.ruby-forum.com/t/model-and-attribute-original-value/126555/3 "2008-01-21T23:51:22Z")

</div>

## Have a look at acts\_as\_audited it does exactly what you want.

Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![nigel.bris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@nigel.bris](https://www.ruby-forum.com/u/nigel.bris)\
**Post date:** [January 24, 2008, 9:41am UTC](https://www.ruby-forum.com/t/model-and-attribute-original-value/126555/4 "2008-01-24T09:41:23Z")

</div>

Both brilliant options… Thank you for your help!
