mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-07 06:54:16 +00:00
Destroy matches if a school wrestler or weight is destroyed
This commit is contained in:
@@ -6,6 +6,10 @@ class School < ActiveRecord::Base
|
|||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
|
|
||||||
|
before_destroy do
|
||||||
|
self.tournament.destroyAllMatches
|
||||||
|
end
|
||||||
|
|
||||||
#calculate score here
|
#calculate score here
|
||||||
def pageScore
|
def pageScore
|
||||||
if self.score == nil
|
if self.score == nil
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ class Tournament < ActiveRecord::Base
|
|||||||
def destroyAllMatches
|
def destroyAllMatches
|
||||||
matches.destroy_all
|
matches.destroy_all
|
||||||
end
|
end
|
||||||
|
if Rails.env.production?
|
||||||
|
handle_asynchronously :destroyAllMatches
|
||||||
|
end
|
||||||
|
|
||||||
def matchesByRound(round)
|
def matchesByRound(round)
|
||||||
matches.joins(:weight).where(round: round).order("weights.max")
|
matches.joins(:weight).where(round: round).order("weights.max")
|
||||||
|
|||||||
@@ -8,6 +8,11 @@ class Wrestler < ActiveRecord::Base
|
|||||||
|
|
||||||
validates :name, :weight_id, :school_id, presence: true
|
validates :name, :weight_id, :school_id, presence: true
|
||||||
|
|
||||||
|
before_destroy do
|
||||||
|
self.tournament.destroyAllMatches
|
||||||
|
self.weight.resetAllSeeds
|
||||||
|
end
|
||||||
|
|
||||||
before_create do
|
before_create do
|
||||||
self.tournament.destroyAllMatches
|
self.tournament.destroyAllMatches
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user