File tree Expand file tree Collapse file tree 5 files changed +29
-6
lines changed Expand file tree Collapse file tree 5 files changed +29
-6
lines changed Original file line number Diff line number Diff line change 2
2
db /* .sqlite3
3
3
log /* .log
4
4
tmp /
5
+ Gemfile.lock
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ gem 'rails', '3.0.7'
4
4
5
5
# Bundle edge Rails instead:
6
6
# gem 'rails', :git => 'git://github.com/rails/rails.git'
7
-
7
+ gem 'heroku'
8
8
gem 'sqlite3'
9
9
gem 'rake' , '0.8.7'
10
10
# Use unicorn as the web server
Original file line number Diff line number Diff line change 30
30
activesupport (3.0.7 )
31
31
arel (2.0.10 )
32
32
builder (2.1.2 )
33
+ configuration (1.2.0 )
33
34
erubis (2.6.6 )
34
35
abstract (>= 1.0.0 )
36
+ heroku (2.1.4 )
37
+ launchy (>= 0.3.2 )
38
+ rest-client (~> 1.6.1 )
39
+ term-ansicolor (~> 1.0.5 )
35
40
i18n (0.5.0 )
41
+ launchy (0.4.0 )
42
+ configuration (>= 0.0.5 )
43
+ rake (>= 0.8.1 )
36
44
mail (2.2.19 )
37
45
activesupport (>= 2.3.6 )
38
46
i18n (>= 0.4.0 )
59
67
rake (>= 0.8.7 )
60
68
thor (~> 0.14.4 )
61
69
rake (0.8.7 )
70
+ rest-client (1.6.1 )
71
+ mime-types (>= 1.16 )
62
72
sqlite3 (1.3.3 )
73
+ term-ansicolor (1.0.5 )
63
74
thor (0.14.6 )
64
75
treetop (1.4.9 )
65
76
polyglot (>= 0.3.1 )
@@ -69,6 +80,7 @@ PLATFORMS
69
80
ruby
70
81
71
82
DEPENDENCIES
83
+ heroku
72
84
rails (= 3.0.7 )
73
85
rake (= 0.8.7 )
74
86
sqlite3
Original file line number Diff line number Diff line change @@ -79,11 +79,7 @@ def update
79
79
def join_team
80
80
@player = Player . find ( params [ :id ] )
81
81
82
- @team = Team . find ( params [ :team_id ] )
83
-
84
- if @team . valid?
85
- @player . team_id = @team . id
86
- end
82
+ @player . team_id = params [ :team_id ]
87
83
88
84
respond_to do |format |
89
85
if @player . save
Original file line number Diff line number Diff line change 1
1
class Team < ActiveRecord ::Base
2
2
belongs_to :game
3
3
has_one :controller , :class_name => "Player"
4
+ has_many :players
4
5
5
6
validates_associated :controller
6
7
validates_presence_of :name
8
+
9
+ validate :ensure_controller_exists
10
+ validate :ensure_team_limit
11
+
12
+ #Teams must have at least 1 player and no more than 4
13
+ #We check for >= 2 and <= 5 because the controller counts as a player, and we don't want to include them
14
+ def ensure_team_limit
15
+ errors . add ( self , 'cannot have more than 4 or less than 1 player' ) unless self . players . count >= 2 and self . players . count <= 5
16
+ end
17
+
18
+ def ensure_controller_exists
19
+ errors . add ( :controller , 'must exist' ) unless self . controller
20
+ end
7
21
end
You can’t perform that action at this time.
0 commit comments