Skip to content

Instantly share code, notes, and snippets.

@lxneng
Created March 2, 2010 05:41
Show Gist options
  • Save lxneng/319171 to your computer and use it in GitHub Desktop.
Save lxneng/319171 to your computer and use it in GitHub Desktop.
change_password
def change_password?(passwords)
self.password_confirmation = passwords[:password_confirmation]
self.verify_password = passwords[:verify_password]
unless verify_password == unencrypted_password
errors.add(:password, "is incorrect")
return false
end
unless passwords[:new_password] == password_confirmation
errors.add(:password, "does not match confirmation")
return false
end
self.password = passwords[:new_password]
save
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment