summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2014-02-27 17:02:10 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2014-02-27 17:02:10 -0500
commitde40ec53e8b80d8d880214183f19ea93172a0026 (patch)
treecb25d099fa0252d2b43db850f21c69ccd03907e3 /app
parent3a7b14f4a51c0fdb8b71720f361a0a8ccf080325 (diff)
give tournaments a game type
Diffstat (limited to 'app')
-rw-r--r--app/controllers/tournaments_controller.rb2
-rw-r--r--app/models/tournament.rb1
-rw-r--r--app/views/tournaments/_form.html.erb4
-rw-r--r--app/views/tournaments/index.html.erb2
-rw-r--r--app/views/tournaments/index.json.jbuilder2
-rw-r--r--app/views/tournaments/show.html.erb5
-rw-r--r--app/views/tournaments/show.json.jbuilder2
7 files changed, 15 insertions, 3 deletions
diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb
index ea3857c..720305f 100644
--- a/app/controllers/tournaments_controller.rb
+++ b/app/controllers/tournaments_controller.rb
@@ -69,6 +69,6 @@ class TournamentsController < ApplicationController
# Never trust parameters from the scary internet, only allow the white list through.
def tournament_params
- params[:tournament]
+ params.require(:tournament).permit(:game_id)
end
end
diff --git a/app/models/tournament.rb b/app/models/tournament.rb
index da3da0e..cc915a0 100644
--- a/app/models/tournament.rb
+++ b/app/models/tournament.rb
@@ -1,2 +1,3 @@
class Tournament < ActiveRecord::Base
+ belongs_to :game
end
diff --git a/app/views/tournaments/_form.html.erb b/app/views/tournaments/_form.html.erb
index 8996266..1fd63e9 100644
--- a/app/views/tournaments/_form.html.erb
+++ b/app/views/tournaments/_form.html.erb
@@ -11,6 +11,10 @@
</div>
<% end %>
+ <div class="field">
+ <%= f.label :game_id %><br>
+ <%= f.text_field :game_id %>
+ </div>
<div class="actions">
<%= f.submit %>
</div>
diff --git a/app/views/tournaments/index.html.erb b/app/views/tournaments/index.html.erb
index 7124111..ad2b7cf 100644
--- a/app/views/tournaments/index.html.erb
+++ b/app/views/tournaments/index.html.erb
@@ -3,6 +3,7 @@
<table>
<thead>
<tr>
+ <th>Game</th>
<th></th>
<th></th>
<th></th>
@@ -12,6 +13,7 @@
<tbody>
<% @tournaments.each do |tournament| %>
<tr>
+ <td><%= tournament.game %></td>
<td><%= link_to 'Show', tournament %></td>
<td><%= link_to 'Edit', edit_tournament_path(tournament) %></td>
<td><%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' } %></td>
diff --git a/app/views/tournaments/index.json.jbuilder b/app/views/tournaments/index.json.jbuilder
index 28d6960..e6f3b49 100644
--- a/app/views/tournaments/index.json.jbuilder
+++ b/app/views/tournaments/index.json.jbuilder
@@ -1,4 +1,4 @@
json.array!(@tournaments) do |tournament|
- json.extract! tournament, :id
+ json.extract! tournament, :id, :game_id
json.url tournament_url(tournament, format: :json)
end
diff --git a/app/views/tournaments/show.html.erb b/app/views/tournaments/show.html.erb
index 2c280ba..30df788 100644
--- a/app/views/tournaments/show.html.erb
+++ b/app/views/tournaments/show.html.erb
@@ -1,4 +1,9 @@
<p id="notice"><%= notice %></p>
+<p>
+ <strong>Game:</strong>
+ <%= @tournament.game %>
+</p>
+
<%= link_to 'Edit', edit_tournament_path(@tournament) %> |
<%= link_to 'Back', tournaments_path %>
diff --git a/app/views/tournaments/show.json.jbuilder b/app/views/tournaments/show.json.jbuilder
index 211799a..0fe65a6 100644
--- a/app/views/tournaments/show.json.jbuilder
+++ b/app/views/tournaments/show.json.jbuilder
@@ -1 +1 @@
-json.extract! @tournament, :id, :created_at, :updated_at
+json.extract! @tournament, :id, :game_id, :created_at, :updated_at