Tag: self

Rails – 自我与@

我正在关注Michael Hartl的RoR教程,它涵盖了密码加密的基础知识。 这是目前的用户模型: class User true, :length => {:maximum => 50} validates :email, :presence => true, :format => {:with => email_regex}, :uniqueness => {:case_sensitive => false} validates :password, :presence => true, :length => {:maximum => 20, :minimum => 6}, :confirmation => true before_save :encrypt_password private def encrypt_password self.encrypted_password = encrypt(password) end def encrypt(string) string end […]