# frozen_string_literal: true

# ActiveRecord Member user
class Member < ApplicationRecord
  has_many :posts
  has_many :comments
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :invitable, :confirmable, :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable
  mount_uploader :avatar, AvatarUploader

  validates :email, presence: true
  validates :username, presence: true

  def fullname
    "#{firstname} #{lastname}"
  end

  def to_param
    username
  end
end

# frozen_string_literal: true

# ActiveRecord Member user
class Member < ApplicationRecord
  has_many :posts
  has_many :comments
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable and :omniauthable
  devise :invitable, :confirmable, :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable
  mount_uploader :avatar, AvatarUploader

  validates :email, presence: true, uniqueness: true
  validates :username, presence: true, uniqueness: true

  def fullname
    "#{firstname} #{lastname}"
  end

  def to_param
    username
  end
end

Validate uniqueness for email and username
Validate uniqueness for email and username
