summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
Diffstat (limited to 'app/models')
-rw-r--r--app/models/match.rb1
-rw-r--r--app/models/tournament.rb13
2 files changed, 14 insertions, 0 deletions
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
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index aa22afa..44b22f5 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -18,4 +18,17 @@ class Tournament < ActiveRecord::Base
end
players<<user
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