mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-06 22:44:14 +00:00
Model validations
This commit is contained in:
@@ -2,6 +2,8 @@ class Mat < ActiveRecord::Base
|
||||
belongs_to :tournament
|
||||
has_many :matches
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
before_destroy do
|
||||
if tournament.matches.size > 0
|
||||
tournament.resetMats
|
||||
|
||||
@@ -3,6 +3,7 @@ class School < ActiveRecord::Base
|
||||
has_many :wrestlers, dependent: :destroy
|
||||
has_many :deductedPoints, through: :wrestlers
|
||||
|
||||
validates :name, presence: true
|
||||
|
||||
#calculate score here
|
||||
def pageScore
|
||||
|
||||
@@ -9,7 +9,7 @@ class Tournament < ActiveRecord::Base
|
||||
has_many :wrestlers, through: :weights
|
||||
has_many :matches, dependent: :destroy
|
||||
|
||||
validates :date, presence: true
|
||||
validates :date, :name, :tournament_type, :address, :director, :director_email , presence: true
|
||||
|
||||
def daysUntil
|
||||
time = (Date.today - self.date).to_i
|
||||
|
||||
@@ -4,6 +4,8 @@ class Weight < ActiveRecord::Base
|
||||
has_many :matches, dependent: :destroy
|
||||
|
||||
attr_accessor :pools
|
||||
|
||||
validates :max, presence: true
|
||||
|
||||
HS_WEIGHT_CLASSES = [106,113,120,132,138,145,152,160,170,182,195,220,285]
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ class Wrestler < ActiveRecord::Base
|
||||
has_many :matches, through: :weight
|
||||
has_many :deductedPoints, class_name: "Teampointadjust"
|
||||
attr_accessor :poolNumber, :poolAdvancePoints
|
||||
|
||||
validates :name, :weight_id, :school_id, presence: true
|
||||
|
||||
before_create do
|
||||
self.tournament.destroyAllMatches
|
||||
|
||||
Reference in New Issue
Block a user