From de40ec53e8b80d8d880214183f19ea93172a0026 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Thu, 27 Feb 2014 17:02:10 -0500 Subject: give tournaments a game type --- app/controllers/tournaments_controller.rb | 2 +- app/models/tournament.rb | 1 + app/views/tournaments/_form.html.erb | 4 ++++ app/views/tournaments/index.html.erb | 2 ++ app/views/tournaments/index.json.jbuilder | 2 +- app/views/tournaments/show.html.erb | 5 +++++ app/views/tournaments/show.json.jbuilder | 2 +- 7 files changed, 15 insertions(+), 3 deletions(-) (limited to 'app') 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 @@ <% end %> +
+ <%= f.label :game_id %>
+ <%= f.text_field :game_id %> +
<%= f.submit %>
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 @@ + @@ -12,6 +13,7 @@ <% @tournaments.each do |tournament| %> + 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 @@

<%= notice %>

+

+ Game: + <%= @tournament.game %> +

+ <%= 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 -- cgit v1.2.3
Game
<%= tournament.game %> <%= link_to 'Show', tournament %> <%= link_to 'Edit', edit_tournament_path(tournament) %> <%= link_to 'Destroy', tournament, method: :delete, data: { confirm: 'Are you sure?' } %>