diff options
author | AndrewMurrell <amurrel@purdue.edu> | 2014-03-06 23:08:42 -0500 |
---|---|---|
committer | AndrewMurrell <amurrel@purdue.edu> | 2014-03-06 23:08:42 -0500 |
commit | 501e305de609313809b2641522679c17834c603f (patch) | |
tree | 068ab7dd64db6e5b9c8441073a0e4db338fd6e89 /app/models | |
parent | 3ce5876375cbb3057ffc96e2886ba57cbd875dc9 (diff) |
Fixed the registration in the tourney model and fixed a lint int the controller.
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/tournament.rb | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 44b22f5..fe781e1 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -25,9 +25,17 @@ class Tournament < ActiveRecord::Base for i in 0..num_matches self.matches.create(name: "Match #{i}") end - #self.players.each_slice(num_teams) do |team_players| - # Team.new(users: team_players) - #end + match_num = 0 + team_num = 0 + self.players.each_slice(@tournament.max_players) do |players| + matches[match_num].teams[team_num] = Team.new(users: players) + if (team_num == 0 and team_num % @tournament.max_teams_per_match == 0) + match_num += 1 + team_num = 0 + else + team_num += 1 + end + end end |