# Best way to determine if a user has modified a record

**URL:** <https://www.ruby-forum.com/t/best-way-to-determine-if-a-user-has-modified-a-record/78836>\
**Category:** Rails\
**Created:** [December 9, 2006, 12:06am UTC](https://www.ruby-forum.com/t/best-way-to-determine-if-a-user-has-modified-a-record/78836 "2006-12-09T00:06:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e5b9ba/32.png) [@dkam](https://www.ruby-forum.com/u/dkam)\
**Post date:** [December 9, 2006, 12:06am UTC](https://www.ruby-forum.com/t/best-way-to-determine-if-a-user-has-modified-a-record/78836/1 "2006-12-09T00:06:27Z")

</div>

When a user edits and submits an existing record I need to perform  
conditional logic based on whether the user has actually changed any of  
the values.

What would be the best way to detect changes? Thanks.

---

<div class="post-metadata">

**Author:** ![dkam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e5b9ba/32.png) [@dkam](https://www.ruby-forum.com/u/dkam)\
**Post date:** [December 9, 2006, 4:41am UTC](https://www.ruby-forum.com/t/best-way-to-determine-if-a-user-has-modified-a-record/78836/2 "2006-12-09T04:41:20Z")

</div>

Save the existing record to a variable before presenting to the user,  
once the user submits, compare the new from the old.

Dan M. wrote:

> When a user edits and submits an existing record I need to perform  
> conditional logic based on whether the user has actually changed any of  
> the values.
> 
> What would be the best way to detect changes? Thanks.

---

<div class="post-metadata">

**Author:** ![dkam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e5b9ba/32.png) [@dkam](https://www.ruby-forum.com/u/dkam)\
**Post date:** [December 9, 2006, 3:11pm UTC](https://www.ruby-forum.com/t/best-way-to-determine-if-a-user-has-modified-a-record/78836/3 "2006-12-09T15:11:22Z")

</div>

[http://svn.viney.net.nz/things/rails/plugins/acts\_as\_modified/](http://svn.viney.net.nz/things/rails/plugins/acts_as_modified/)

@person = Person.find(:first)  
@person.modified?

-Jonathan.

---

<div class="post-metadata">

**Author:** ![dkam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e5b9ba/32.png) [@dkam](https://www.ruby-forum.com/u/dkam)\
**Post date:** [December 10, 2006, 6:40am UTC](https://www.ruby-forum.com/t/best-way-to-determine-if-a-user-has-modified-a-record/78836/4 "2006-12-10T06:40:45Z")

</div>

Perfect, thanks.
