36 lines
1011 B
Ruby
36 lines
1011 B
Ruby
# == Schema Information
|
|
#
|
|
# Table name: completions
|
|
#
|
|
# id :integer not null, primary key
|
|
# time_seconds :integer
|
|
# created_at :datetime not null
|
|
# updated_at :datetime not null
|
|
# contest_id :integer not null
|
|
# contestant_id :integer not null
|
|
# puzzle_id :integer not null
|
|
#
|
|
# Indexes
|
|
#
|
|
# index_completions_on_contest_id (contest_id)
|
|
# index_completions_on_contestant_id (contestant_id)
|
|
# index_completions_on_puzzle_id (puzzle_id)
|
|
#
|
|
# Foreign Keys
|
|
#
|
|
# contest_id (contest_id => contests.id)
|
|
# contestant_id (contestant_id => contestants.id)
|
|
# puzzle_id (puzzle_id => puzzles.id)
|
|
#
|
|
class Completion < ApplicationRecord
|
|
belongs_to :contest
|
|
belongs_to :contestant
|
|
belongs_to :puzzle
|
|
|
|
attr_accessor :display_time_from_start, :display_relative_time
|
|
|
|
validates :time_seconds, presence: true
|
|
validates_numericality_of :time_seconds
|
|
validates :puzzle_id, uniqueness: { score: :contestant }
|
|
end
|