I did a really kludgy fix last night using attr_protected, and I like certain aspects of your idea as well. If I find some time tonight I'll probably take a look at the code again to try and work out a more "beautiful" option for myself. :)
Thanks for your help! On Nov 24, 11:53 am, Thorsten Müller <[EMAIL PROTECTED]> wrote: > I use some code like this: > > attr_accessor :new_password > > validates_presence_of :new_password, :on => :create > validates_length_of :new_password, :minimum => 6, :allow_nil => > true, :allow_blank => true, :unless => :new_password.blank? > validates_confirmation_of :new_password > > before_save :set_encrypted_password > > def set_encrypted_password > write_attribute(:password, Client.encrypt_password(@new_password)) > unless @new_password.nil? || @new_password.blank? > end > > def self.encrypt_password(password) > Digest::SHA1.hexdigest("something_random_goes_here_#{password}") > end > > def self.authenticate(email, password) > find_by_email_and_password_and_active(email, encrypt_password > (password), true) > end --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---