blob: afdd27e15ec1b462f7958ea4fe26c25f9fb83557 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
class Tournament < ActiveRecord::Base
belongs_to :game
has_many :users, :through => :user_tournament_pair
def open?
return true
end
def joinable_by?(user)
return ((not user.nil?) and user.in_group?(:player) and open?)
end
def join(user)
unless joinable?(user)
return false
end
pair = new_user_tournament_pair(user: user)
return pair.save
end
end
|