1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-03-25 01:14:43 +00:00

Fix calculate team scores

This commit is contained in:
2021-12-21 01:23:28 +00:00
parent a6cc05424c
commit b571bcc749
2 changed files with 10 additions and 4 deletions

View File

@@ -14,11 +14,11 @@ class TournamentsController < ApplicationController
end
def calculate_team_scores
@tournament.schools.each do |school|
school.calculate_score
end
respond_to do |format|
format.html { redirect_to "/tournaments/#{@tournament.id}", notice: 'Team scores are calcuating.' }
if @tournament.calculate_all_team_scores
format.html { redirect_to "/tournaments/#{@tournament.id}", notice: 'Team scores are calcuating.' }
format.json { render action: 'show', status: :created, location: @tournament }
end
end
end

View File

@@ -40,6 +40,12 @@ class Tournament < ActiveRecord::Base
end
end
def calculate_all_team_scores
self.schools.each do |school|
school.calculate_score
end
end
def create_pre_defined_weights(weight_classes)
weights.destroy_all
weight_classes.each do |w|