class Run < ApplicationRecord belongs_to :game belongs_to :user has_many :checkpoints, dependent: :destroy validates :title, presence: true def checked_in? last_checkpoint = checkpoints.where.not(kind: :comment).last # If there are no non-comment checkpoints, then the run was never checked in. last_checkpoint.nil? ? false : last_checkpoint.checkin? end end