From a1fbcc4a9f4d8c8fd4b33f5844473be9c5802259 Mon Sep 17 00:00:00 2001 From: jcwimer Date: Wed, 25 Mar 2015 13:08:36 +0000 Subject: [PATCH] Added weight_max to matchup --- app/models/matchup.rb | 7 +------ app/models/pool.rb | 1 + app/models/poolbracket.rb | 1 + app/models/tournament.rb | 2 +- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/models/matchup.rb b/app/models/matchup.rb index 8180646..b08ad5b 100644 --- a/app/models/matchup.rb +++ b/app/models/matchup.rb @@ -1,11 +1,6 @@ class Matchup - attr_accessor :w1, :w2, :round, :weight_id, :boutNumber, :w1_name, :w2_name, :bracket_position, :bracket_position_number + attr_accessor :w1, :w2, :round, :weight_id, :boutNumber, :w1_name, :w2_name, :bracket_position, :bracket_position_number, :weight_max - def weight_max - @weight = Weight.find(self.weight_id) - return @weight.max - end - def to_hash hash = {} instance_variables.each {|var| hash[var.to_s.delete("@")] = instance_variable_get(var) } diff --git a/app/models/pool.rb b/app/models/pool.rb index 85c5a5a..3cb156b 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -23,6 +23,7 @@ class Pool @match.w2_name = b[1].name @match.weight_id = weight.id @match.round = index + 1 + @match.weight_max = weight.max matches << @match end end diff --git a/app/models/poolbracket.rb b/app/models/poolbracket.rb index a46f9b0..dc90c6e 100644 --- a/app/models/poolbracket.rb +++ b/app/models/poolbracket.rb @@ -95,6 +95,7 @@ class Poolbracket @match.round = round @match.bracket_position = bracket_position @match.bracket_position_number = bracket_position_number + @match.weight_max = weight.max matches << @match return matches end diff --git a/app/models/tournament.rb b/app/models/tournament.rb index ad10ac8..fffacf2 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -11,7 +11,7 @@ class Tournament < ActiveRecord::Base end def upcomingMatches - if self.matchups_array? + if self.matchups_array return matchupHashesToObjects(self.matchups_array) else @matches = generateMatchups