From e10bf58ec059ec263c1d1a9dcac608475377868a Mon Sep 17 00:00:00 2001 From: nfoy Date: Thu, 6 Mar 2014 20:39:05 -0500 Subject: matches routed --- app/models/match.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'app/models') diff --git a/app/models/match.rb b/app/models/match.rb index 533435a..8acebf7 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -1,3 +1,4 @@ class Match < ActiveRecord::Base belongs_to :tournament + end -- cgit v1.2.3-2-g168b From 2bfc17c39f9b8b5ea71d36d2d5f041295f24192f Mon Sep 17 00:00:00 2001 From: Tomer Kimia Date: Thu, 6 Mar 2014 22:06:32 -0500 Subject: tournaments setup started. NOT FINISHED --- app/models/tournament.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app/models') diff --git a/app/models/tournament.rb b/app/models/tournament.rb index 26dec72..c359b1c 100644 --- a/app/models/tournament.rb +++ b/app/models/tournament.rb @@ -19,4 +19,17 @@ class Tournament < ActiveRecord::Base pair = UserTournamentPair.new(tournament: self, user: user) return pair.save end + + def setup + num_teams = (self.users.count/self.players_per_team).floor + num_matches = num_teams - 1 + 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 + end + + end -- cgit v1.2.3-2-g168b