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.
Ead43bcb0202410540a6a7cee5955d46?d=identicon&s=25 Fresh Mix (giga)
on 2009-03-16 19: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?
2505b282d57c29be797dc35b245adb4c?d=identicon&s=25 Philip Hallstrom (Guest)
on 2009-03-16 19: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.