Add completions
Some checks are pending
CI / scan_ruby (push) Waiting to run
CI / scan_js (push) Waiting to run
CI / lint (push) Waiting to run
CI / test (push) Waiting to run

This commit is contained in:
sto
2025-03-20 11:12:55 +01:00
parent 44507bb85c
commit a03907f756
20 changed files with 213 additions and 14 deletions

7
app/models/completion.rb Normal file
View File

@@ -0,0 +1,7 @@
class Completion < ApplicationRecord
belongs_to :contest
belongs_to :contestant
belongs_to :puzzle
validates :time_seconds, presence: true
end

View File

@@ -1,5 +1,7 @@
class Contest < ApplicationRecord
belongs_to :user
has_many :completions, dependent: :destroy
has_many :contestants, dependent: :destroy
has_many :puzzles, dependent: :destroy
end

View File

@@ -1,4 +1,7 @@
class Contestant < ApplicationRecord
belongs_to :contest
has_many :completions
validates :name, presence: true
end

View File

@@ -1,6 +1,9 @@
class Puzzle < ApplicationRecord
belongs_to :contest
has_many :completions
has_one_attached :image
validates :name, presence: true
validates :brand, presence: true
end