# -*- encoding : utf-8 -*-
class Inscrit < ActiveRecord::Base

  before_validation :verify
  
  validates :email,:presence => true,:uniqueness => true, :format => { :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i }



  protected
  def verify(size=16)
    if !self.verify_key
      s = ""
      size.times { s << (i = Kernel.rand(62); i += ((i < 10) ? 48 : ((i < 36) ? 55 : 61 ))).chr }
      self.verify_key = s
    end
  end
  
  
end
