Files
puzzle-scoreboard/app/models/contest.rb
sto aea001cdf6
Some checks failed
CI / scan_ruby (push) Successful in 20s
CI / scan_js (push) Successful in 15s
CI / lint (push) Failing after 13s
CI / test (push) Successful in 38s
Add contest param for offline form participation
2025-10-30 10:30:32 +01:00

44 lines
1.2 KiB
Ruby

# == Schema Information
#
# Table name: contests
#
# id :integer not null, primary key
# allow_registration :boolean default(FALSE)
# lang :string default("en")
# name :string
# offline_form :boolean default(FALSE)
# public :boolean default(FALSE)
# slug :string
# team :boolean default(FALSE)
# created_at :datetime not null
# updated_at :datetime not null
# user_id :integer not null
#
# Indexes
#
# index_contests_on_slug (slug) UNIQUE
# index_contests_on_user_id (user_id)
#
# Foreign Keys
#
# user_id (user_id => users.id)
#
class Contest < ApplicationRecord
extend FriendlyId
belongs_to :user
has_many :categories
has_many :completions, dependent: :destroy
has_many :contestants, dependent: :destroy
has_many :puzzles, dependent: :destroy
has_many :messages, dependent: :destroy
has_many :offlines, dependent: :destroy
friendly_id :name, use: :slugged
validates :name, presence: true
validates :lang, inclusion: { in: Languages::AVAILABLE_LANGUAGES.map { |lang| lang[:id] } }
generates_token_for :token
end