Hi to all!

Sorry, but I'm ruby & sequel beginner. I have a problem with the 
before_update callback. I've read the doc pages and I've searched in this 
google group without luck.

I have the next sequel model:

  class User < Sequel::Model(DB[:users])
    plugin :validation_helpers
    
    def validate
      super
      validates_presence [:email, :password, :nickname]
    end

    def before_create
      self[:id] ||= UUID.create
      self[:password] = Digest::SHA1.hexdigest(self[:password])
      self[:created] ||= Date.today
      self[:created_extended] ||= DateTime.now
      super
    end
  end


I want to encrypt the password inside the before_update hook only if new 
password has been set. 
If the update method not set a password, self[:password] have the current 
password. But if the update method, self[:password] have the new password.

Can you point me any way to get the old password to compare it with the new 
one without doing another find inside the before_update? something like ||= 
maybe?



I hope someone can help me or show me the way.

thanks for advance,
Israel

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/sequel-talk/-/psKD_Rzx7XcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sequel-talk?hl=en.

Reply via email to