Forum: Ruby on Rails Use callbacks to determine model field changes?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
3ff9c2544554b13c6c7877e76684751b?d=identicon&s=25 Lee Smith (smitjel)
on 2009-05-27 16:26
(Received via mailing list)
What's the best way to examine what fields on a model are changing?
Would you use a callback to do that and how?

I guess the simplest example of this is how lighthouseapp documents
changes that a person makes to a ticket:

Milestone changed from “2.x” to “3.0”

State changed from “new” to “open”

How could I accomplish the same thing?
8cac6e764279d4ca612f4a6ec767fdaf?d=identicon&s=25 Benjamin Curtis (Guest)
on 2009-05-27 16:32
(Received via mailing list)
Take a look at
Benjamin Curtis - Ready-made Rails code - Team-powered recruiting - Personal blog
B14575f0ca69f10938fdd67e7156e0e1?d=identicon&s=25 Craig Demyanovich (Guest)
on 2009-05-27 16:32
(Received via mailing list)
If you're on Rails >= 2.1, you can track attribute changes:

You might also like Ryan Bates' screencast on the topic:


Craig Demyanovich
Mutually Human Software
3ff9c2544554b13c6c7877e76684751b?d=identicon&s=25 Lee Smith (smitjel)
on 2009-05-28 20:16
(Received via mailing list)
Thanks for the help guys.

However, I've now hit the trap where I need session data in the
observer (who is changing the model)...
This topic is locked and can not be replied to.