summaryrefslogtreecommitdiff
path: root/app/models/tournament.rb
diff options
context:
space:
mode:
authorTomer Kimia <tkimia@purdue.edu>2014-04-01 17:14:05 -0400
committerTomer Kimia <tkimia@purdue.edu>2014-04-01 17:14:05 -0400
commit0867bc68749873aa131c0f3b273771b5f70ae778 (patch)
treed29a091054b4ac659af77072f55be1e7b1bf69cf /app/models/tournament.rb
parentcd6b94cfc989800d65acc0fbceeebe35da5be4af (diff)
players can now leave tournaments
Diffstat (limited to 'app/models/tournament.rb')
-rw-r--r--app/models/tournament.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index 69bedf5..21dc9bb 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -19,6 +19,12 @@ class Tournament < ActiveRecord::Base
players.push(user)
end
+ def leave(user)
+ if players.include?(user)
+ players.delete(user)
+ end
+ end
+
def setup(tournament)
num_teams = (self.players.count/self.max_players_per_team).floor
num_matches = num_teams - 1