Add completions
This commit is contained in:
7
app/models/completion.rb
Normal file
7
app/models/completion.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class Completion < ApplicationRecord
|
||||
belongs_to :contest
|
||||
belongs_to :contestant
|
||||
belongs_to :puzzle
|
||||
|
||||
validates :time_seconds, presence: true
|
||||
end
|
@@ -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
|
||||
|
@@ -1,4 +1,7 @@
|
||||
class Contestant < ApplicationRecord
|
||||
belongs_to :contest
|
||||
|
||||
has_many :completions
|
||||
|
||||
validates :name, presence: true
|
||||
end
|
||||
|
@@ -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
|
||||
|
Reference in New Issue
Block a user