summaryrefslogtreecommitdiff
path: root/app/models/user.rb
blob: 6b0f4626a1578a3c31d036bce9ee468340b6fdbb (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 captured_pokemon
    Pokemon.joins(:pokedex_entries).where(pokedex_entries: {user_id: id}).distinct
  end
end