mirror of
https://github.com/jcwimer/wrestlingApp
synced 2026-04-16 13:03:37 +00:00
Got stuff working with matches being saved individually.
This commit is contained in:
@@ -8,12 +8,10 @@ class Tournament < ActiveRecord::Base
|
||||
serialize :matchups_array
|
||||
|
||||
def upcomingMatches
|
||||
# @matches = generateMatchups
|
||||
if self.matches.nil?
|
||||
return self.matches
|
||||
else
|
||||
@matches = generateMatchups
|
||||
puts @matches.inspect
|
||||
saveMatchups(@matches)
|
||||
return @matches
|
||||
end
|
||||
@@ -25,6 +23,7 @@ class Tournament < ActiveRecord::Base
|
||||
@matches = weight.generateMatchups(@matches)
|
||||
end
|
||||
@matches = assignBouts(@matches)
|
||||
@matches = Losernamegen.new.assignLoserNames(@matches,self.weights)
|
||||
return @matches
|
||||
end
|
||||
|
||||
@@ -36,38 +35,9 @@ class Tournament < ActiveRecord::Base
|
||||
|
||||
def saveMatchups(matches)
|
||||
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
|
||||
m.save
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def matchupObjectsToHash(matches)
|
||||
array_of_hashes = []
|
||||
matches.each do |m|
|
||||
@matchHash = m.to_hash
|
||||
array_of_hashes << @matchHash
|
||||
end
|
||||
return array_of_hashes
|
||||
end
|
||||
|
||||
def matchupHashesToObjects(matches)
|
||||
array_of_objects = []
|
||||
matches.each do |m|
|
||||
@match = Matchup.new
|
||||
@match.convert_to_obj(m)
|
||||
array_of_objects << @match
|
||||
end
|
||||
return array_of_objects
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user