summaryrefslogtreecommitdiff
path: root/app/models/run.rb
blob: 023202bde7d359bfb526f4f8a97e3a6824d475b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
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