class User < ApplicationRecord validates :email, uniqueness: true, presence: true, :on => :create validates :username, uniqueness: true, presence: true, :on => :create validates :email, format:{ with: /\S+@\S+[.]\S+/, message: "Must be a valid email format." } validates :password_digest, presence: true has_many :created_activities, foreign_key: 'author_id', class_name: 'Activity', dependent: :destroy has_secure_password end