# Has\_changed? - how best to?

**URL:** <https://www.ruby-forum.com/t/has-changed-how-best-to/103947>\
**Category:** Rails\
**Created:** [May 11, 2007, 9:40pm UTC](https://www.ruby-forum.com/t/has-changed-how-best-to/103947 "2007-05-11T21:40:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [May 11, 2007, 9:40pm UTC](https://www.ruby-forum.com/t/has-changed-how-best-to/103947/1 "2007-05-11T21:40:20Z")

</div>

Anybody know of a built-in method, filter, or plugin that will check to  
see if any of the values in an object have been changed since .new or  
.find begat it? I’m looking for something that will let me easily do a  
before\_save filter that looks like…

before\_save :reassign\_if\_changed

def reassign\_if\_changed  
if self.has\_changed?  
self.last\_modified\_by = @visitor.name  
end  
end

I don’t want to change the last\_modified\_by value just because a visitor  
opens an edit page, even if they click the submit button. I only want  
to change it if the visitor has actually changed the original  
information.

Thanks in advance for any thoughts on how best to accomplish this.

Best regards,  
Bill

---

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [May 11, 2007, 11:05pm UTC](https://www.ruby-forum.com/t/has-changed-how-best-to/103947/2 "2007-05-11T23:05:30Z")

</div>

> end  
> end
> 
> I don’t want to change the last\_modified\_by value just because a visitor  
> opens an edit page, even if they click the submit button. I only want  
> to change it if the visitor has actually changed the original  
> information.
> 
> Thanks in advance for any thoughts on how best to accomplish this.

Maybe… [http://agilewebdevelopment.com/plugins/acts\_as\_modified](http://agilewebdevelopment.com/plugins/acts_as_modified)

This plugin lets you track attribute changes to an ActiveRecord object.

---

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [May 12, 2007, 3:58am UTC](https://www.ruby-forum.com/t/has-changed-how-best-to/103947/3 "2007-05-12T03:58:51Z")

</div>

Hi Philip,

----- Original Message -----  
Philip H. wrote:

> Maybe… [http://agilewebdevelopment.com/plugins/acts\_as\_modified](http://agilewebdevelopment.com/plugins/acts_as_modified)
> 
> This plugin lets you track attribute changes to an ActiveRecord object.

Thanks for the link. I guess I’m going to have to just dig in and put  
together a little sandbox app. The “here’s what this does” info on that  
and  
the related plugin is so sparse …

Best regards,  
Bill
