Forum: Ruby on Rails Auto update model

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.
Fresh M. (Guest)
on 2009-03-16 20:11
I have a model: user (id, username, password, ... key), where "key" is
sha1 hach of username + password.
How can I update key every time when user update own information?
Philip H. (Guest)
on 2009-03-16 20:25
(Received via mailing list)
> I have a model: user (id, username, password, ... key), where "key" is
> sha1 hach of username + password.
> How can I update key every time when user update own information?

Look into the "before_save" callback, check to see if values have
changed and if so set a new key.

-philip
This topic is locked and can not be replied to.