Forum: Ruby on Rails Acessing new field values in validate_on_update

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.
F75ea35d0ffa8468c61f1fb2347a8000?d=identicon&s=25 Jon (Guest)
on 2007-06-08 22:28
(Received via mailing list)
Hello,

How to access to old field values in validate_on_update method? I need
to see if there is changed field's value and if it is so, rise an
error.

Thank you!
19990e3fa0fc68c874f42f13d1500011?d=identicon&s=25 Steve Rawlinson (trip)
on 2007-06-11 17:56
I haven't tested this but you could try using Model.find() to get the
version of the object from the database which will as yet be unmodified
by the save. Then compare the fields with the (unsaved) version to see
if changes have been made.

Try it, if it doesnt work I'll suggest something else.

steve
This topic is locked and can not be replied to.