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
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Group < ApplicationRecord
|
class Group < ApplicationRecord
|
||||||
belongs_to :matches
|
belongs_to :stage
|
||||||
belongs_to :teams
|
has_many :matches, dependent: :destroy
|
||||||
|
has_many :group_scores, dependent: :destroy
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,4 +2,5 @@
|
||||||
|
|
||||||
class GroupScore < ApplicationRecord
|
class GroupScore < ApplicationRecord
|
||||||
belongs_to :team
|
belongs_to :team
|
||||||
|
belongs_to :group
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
class Match < ApplicationRecord
|
class Match < ApplicationRecord
|
||||||
|
belongs_to :stage
|
||||||
|
belongs_to :group
|
||||||
|
has_many :scores, dependent: :destroy
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
class Team < ApplicationRecord
|
class Team < ApplicationRecord
|
||||||
belongs_to :tournament
|
belongs_to :tournament
|
||||||
|
has_many :group_scores, dependent: :destroy
|
||||||
has_one :group_score, dependent: :destroy
|
has_many :scores, dependent: :destroy
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -3,12 +3,13 @@
|
||||||
require 'securerandom'
|
require 'securerandom'
|
||||||
|
|
||||||
class Tournament < ApplicationRecord
|
class Tournament < ApplicationRecord
|
||||||
|
belongs_to :user
|
||||||
|
has_many :teams, dependent: :destroy
|
||||||
|
has_many :stages, dependent: :destroy
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
validates :code, presence: true, uniqueness: true
|
validates :code, presence: true, uniqueness: true
|
||||||
|
|
||||||
has_many :teams, dependent: :destroy
|
|
||||||
belongs_to :user
|
|
||||||
|
|
||||||
alias_attribute :owner, :user
|
alias_attribute :owner, :user
|
||||||
|
|
||||||
after_initialize do |tournament|
|
after_initialize do |tournament|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue