I am using require 'digest/sha1' to encrypt my password and save into database. During login it is showing the following error-
undefined local variable or method `encrypted_password' for #<Signin:0x992c990
code:
before_save :encrypt_password
def has_password?(submitted_password) encrypted_password == encrypt(submitted_password) end
private
def encrypt_password self.salt = make_salt unless has_password?(password) self.encrypted_password = encrypt(password) end
def encrypt(string) secure_hash("#{salt}--#{string}") end
def make_salt secure_hash("#{Time.now.utc}--#{password}") end
def secure_hash(string) Digest::SHA2.hexdigest(string) end
Please help me dis !