Modify model associations to map to new schema
This commit is contained in:
parent
c573fd9edd
commit
65abada8b2
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Group < ApplicationRecord
|
||||
belongs_to :matches
|
||||
belongs_to :teams
|
||||
belongs_to :stage
|
||||
has_many :matches, dependent: :destroy
|
||||
has_many :group_scores, dependent: :destroy
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@
|
|||
|
||||
class GroupScore < ApplicationRecord
|
||||
belongs_to :team
|
||||
belongs_to :group
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Match < ApplicationRecord
|
||||
belongs_to :stage
|
||||
belongs_to :group
|
||||
has_many :scores, dependent: :destroy
|
||||
end
|
||||
|
|
|
|||
|
|
@ -2,6 +2,6 @@
|
|||
|
||||
class Team < ApplicationRecord
|
||||
belongs_to :tournament
|
||||
|
||||
has_one :group_score, dependent: :destroy
|
||||
has_many :group_scores, dependent: :destroy
|
||||
has_many :scores, dependent: :destroy
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,12 +3,13 @@
|
|||
require 'securerandom'
|
||||
|
||||
class Tournament < ApplicationRecord
|
||||
belongs_to :user
|
||||
has_many :teams, dependent: :destroy
|
||||
has_many :stages, dependent: :destroy
|
||||
|
||||
validates :name, presence: true
|
||||
validates :code, presence: true, uniqueness: true
|
||||
|
||||
has_many :teams, dependent: :destroy
|
||||
belongs_to :user
|
||||
|
||||
alias_attribute :owner, :user
|
||||
|
||||
after_initialize do |tournament|
|
||||
|
|
|
|||
Loading…
Reference in New Issue