Forum: Ruby on Rails in after_update, possible to see previous value of record?

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.
B3704e5f5327b11254091a936d08eb99?d=identicon&s=25 dan kuwachi (Guest)
on 2007-03-09 23:36
(Received via mailing list)
I have this situation where in an after_update, I would like to know
the previous value of the record instead of simply being notified the
record has been updated.

For example let's say I had a table called 'foo' which had a field
'new_flag'.  I want to know when the 'new_flag' field changes from 0 --
> 1 in an after_update so I can do some business logic in the
after_update.  My problem is in the after_update I don't know how to
detect if that particular field got updated.

Is there some api call I can use to access the old object?

thanks!
-dan
E3640176765dae2465d33ef6eb114691?d=identicon&s=25 bcparanj@gmail.com (Guest)
on 2007-03-10 03:05
(Received via mailing list)
Use the acts_as_versioned plugin
http://wiki.rubyonrails.com/rails/pages/ActsAsVersioned.
You can use the API that will allow you to call the previous version
object and access its values.
This topic is locked and can not be replied to.