:pending_account after_save :encrypt_password email_regex = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i # add an exact lucene index on the email property property :email, :index => :exact has_one(:avatar).to(Avatar) validates :email, :presence => true,:format => { :with => email_regex } validates :email, :uniqueness => true, :unless => :pending_account? accepts_nested_attributes_for :avatar, :allow_destroy => true end