1
0
mirror of https://github.com/jcwimer/wrestlingApp synced 2026-04-09 23:44:52 +00:00

Revert "Revert "Moving away from matchups_array and saving matches individually""

This reverts commit 7b3fe2aaad.
This commit is contained in:
2015-04-25 21:44:08 -04:00
parent 7b3fe2aaad
commit b86211102b
6 changed files with 67 additions and 11 deletions

View File

@@ -9,12 +9,13 @@ class Tournament < ActiveRecord::Base
def upcomingMatches
# @matches = generateMatchups
if self.matchups_array
return matchupHashesToObjects(self.matchups_array)
if self.matches.nil?
return self.matches
else
@matches = generateMatchups
saveMatchups(@matches)
return @matches
puts @matches.inspect
saveMatchups(@matches)
return @matches
end
end
@@ -34,8 +35,18 @@ class Tournament < ActiveRecord::Base
end
def saveMatchups(matches)
self.matchups_array = matchupObjectsToHash(matches)
self.save
matches.each do |m|
@match = Match.new
@match.w1 = m.w1
@match.w2 = m.w2
@match.round = m.round
@match.boutNumber = m.boutNumber
@match.bracket_position = m.bracket_position
@match.bracket_position_number = m.bracket_position_number
@match.tournament_id = self.id
puts @match.inspect
@match.save
end
end