summaryrefslogtreecommitdiff
path: root/app/models/user.rb
blob: 4ad0a1ed125ecf02c722c6f7165c33ad33726a35 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
class User < ApplicationRecord
  # Include default devise modules. Others available are:
  # :confirmable, :lockable, :timeoutable, :trackable and :omniauthable
  devise :database_authenticatable, :rememberable

  has_many :checkpoints, through: :runs
  has_many :pokedex_entries, dependent: :destroy
  has_many :runs, dependent: :restrict_with_error

  def pokedex_captured_count
    pokedex_entries.joins(:pokemon).select("distinct pokemons.pokedex_num").count
  end
end