1. 邮箱验证
VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-]+(\.[a-z\d\-]+)*\.[a-z]+\z/i
validates :email, presence: true, length: { maximum: 255 }, format: { with: VALID_EMAIL_REGEX }

Rails零散知识-LMLPHP

2.md5加密
 在 Ruby 中,MD5 哈希算法由 Digest 库中的 hexdigest 方法实现:
  >> email = "[email protected]"
  >> Digest::MD5::hexdigest(email.downcase)
  => "1fda4469bcbec3badf5418269ffc5968"
  
  
05-28 21:01