Forum: Ruby on Rails has_changed? - how best to?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2007-05-11 21:40
(Received via mailing list)
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
2f9a03aa0fcfe945229cb6126eda2cb2?d=identicon&s=25 Philip Hallstrom (Guest)
on 2007-05-11 23:05
(Received via mailing list)
>  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.
2b891e820c238ded365d035771603f21?d=identicon&s=25 Bill Walton (Guest)
on 2007-05-12 03:58
(Received via mailing list)
Hi Philip,

----- Original Message -----
Philip Hallstrom 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
This topic is locked and can not be replied to.