1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-30 19:22:21 +00:00
Files
wrestlingdev.com/app/models/school.rb
2015-11-16 16:59:08 +00:00

32 lines
529 B
Ruby

class School < ActiveRecord::Base
belongs_to :tournament
has_many :wrestlers, dependent: :destroy
has_many :deductedPoints, through: :wrestlers
#calculate score here
def score
calcScore
end
def calcScore
totalWrestlerPoints - totalDeductedPoints
end
def totalWrestlerPoints
points = 0
self.wrestlers.each do |w|
points = points + w.totalTeamPoints
end
points
end
def totalDeductedPoints
points = 0
self.deductedPoints.each do |d|
points = points + d.points
end
points
end
end