Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixup seeds, repair player_stats reporting

  • Loading branch information...
commit f6a740b43eb5e4b7c8e1a02c1e59466558559eb1 1 parent f01f7b7
@cfebs authored
View
5 app/controllers/matches_controller.rb
@@ -4,11 +4,14 @@ def index
end
def new
- @match = Match.new
+ @season = Season.find(params[:season_id])
+ @match = @season.matches.build
end
def create
+ @season = Season.find(params[:season_id])
@match = Match.new(params[:match])
+ @season.matches << @match
if @match.save
#redirect_to matches_player_stats
View
6 app/views/matches/new.html.erb
@@ -1,12 +1,12 @@
<h1>Matches#new</h1>
-<%= form_for @match do |f| %>
+<%= form_for [@season, @match] do |f| %>
<%= errors_for @match %>
<div class="span-24">
<div class="span-12">
<h2>Home</h2>
<p>
- <%= f.collection_select :home_team_id, Team.all, :id, :name, :prompt => true %>
+ <%= f.collection_select :home_team_id, @season.teams, :id, :name, :prompt => true %>
</p>
<hr>
<p>
@@ -19,7 +19,7 @@
<div class="span-12 last">
<h2>Away</h2>
<p>
- <%= f.collection_select :away_team_id, Team.all, :id, :name, :prompt => true %>
+ <%= f.collection_select :away_team_id, @season.teams, :id, :name, :prompt => true %>
</p>
<hr>
<p>
View
5 app/views/matches/show.html.erb
@@ -1,7 +1,10 @@
<h1>Matches#show</h1>
+<p>
+ <%= link_to 'back to season', season_path(@match.season) %>
+</p>
<div class="span-24">
<div class="span-12">
- <h2><%= @match.home_team.name %> <%= @match.away_team_score %></h2>
+ <h2><%= @match.home_team.name %> <%= @match.home_team_score %></h2>
<hr>
<h3>Player Stats</h3>
<table>
View
8 db/seeds.rb
@@ -7,7 +7,7 @@
# Mayor.create(name: 'Emanuel', city: cities.first)
league = League.create(name: 'TF2fpg')
-season = league.season.create(name: 'TF2fpg1')
+season = league.seasons.create(name: 'TF2fpg1')
frag = season.teams.create(name: 'Frag', tag: '`fp-')
ruth = season.teams.create(name: 'Ruthless', tag: 'R7')
@@ -16,6 +16,6 @@
frag.members.create(alias: 'coco')
frag.members.create(alias: 'ricr')
-ruth.members.create(alias: 'jesus')
-ruth.members.create(alias: 'jesus')
-ruth.members.create(alias: 'jesus')
+ruth.members.create(alias: 'blade')
+ruth.members.create(alias: 'idk')
+ruth.members.create(alias: 'again')
Please sign in to comment.
Something went wrong with that request. Please try again.