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