Has_changed? - how best to?


#1

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


#2

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

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


#3

Hi Philip,

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

Maybe… 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