user.rb revision 279dfe8d07ff651880bd08dba5a7c73a95213e5e
scope :autocomplete_search, ->(query) {
limit(10).where("name ILIKE ? OR email ILIKE ?", "%" << query << "%", query)
}
def to_s
name? ? name : email.split("@").first
end
# marks the user as deleted
def delete
self.encrypted_password = nil
self.deleted_at = Time.now
# nullify email fields
@bypass_postpone = true
self.email = nil
self.unconfirmed_email = nil
save(:validate => false)
end
def email_required?
deleted_at.nil?
end
end