From 451e6911f8039889b7a805dcf6d1cda3e23e45c1 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 1 Apr 2015 13:44:01 +0000 Subject: [PATCH] Fixed totalRounds in weight --- app/models/weight.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/models/weight.rb b/app/models/weight.rb index d41a472..81803d9 100644 --- a/app/models/weight.rb +++ b/app/models/weight.rb @@ -123,7 +123,16 @@ class Weight < ActiveRecord::Base def totalRounds(matches) @matchups = matches.select{|m| m.weight_id == self.id} - return @matchups.sort_by{|m| m.round}.last.round + @lastRound = matches.sort_by{|m| m.round}.last.round + @count = 0 + @round =1 + until @round > @lastRound do + if @matchups.select{|m| m.round == @round} + @count = @count + 1 + end + @round = @round + 1 + end + return @count end end