diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/controllers/matches_controller.rb | 2 | ||||
-rw-r--r-- | app/models/match.rb | 1 | ||||
-rw-r--r-- | app/views/matches/_form.html.erb | 4 | ||||
-rw-r--r-- | app/views/matches/index.html.erb | 2 | ||||
-rw-r--r-- | app/views/matches/index.json.jbuilder | 2 | ||||
-rw-r--r-- | app/views/matches/show.html.erb | 5 | ||||
-rw-r--r-- | app/views/matches/show.json.jbuilder | 2 |
7 files changed, 15 insertions, 3 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 984be3f..8329da5 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -69,6 +69,6 @@ class MatchesController < ApplicationController # Never trust parameters from the scary internet, only allow the white list through. def match_params - params.require(:match).permit(:tournament_id, :name) + params.require(:match).permit(:tournament_id, :name, :winner_id) end end diff --git a/app/models/match.rb b/app/models/match.rb index 533435a..bb814c1 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -1,3 +1,4 @@ class Match < ActiveRecord::Base belongs_to :tournament + belongs_to :winner end diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb index c5f1ba8..f1e6047 100644 --- a/app/views/matches/_form.html.erb +++ b/app/views/matches/_form.html.erb @@ -19,6 +19,10 @@ <%= f.label :name %><br> <%= f.text_field :name %> </div> + <div class="field"> + <%= f.label :winner_id %><br> + <%= f.text_field :winner_id %> + </div> <div class="actions"> <%= f.submit %> </div> diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 0742770..71db08c 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -5,6 +5,7 @@ <tr> <th>Tournament</th> <th>Name</th> + <th>Winner</th> <th></th> <th></th> <th></th> @@ -16,6 +17,7 @@ <tr> <td><%= match.tournament %></td> <td><%= match.name %></td> + <td><%= match.winner %></td> <td><%= link_to 'Show', match %></td> <td><%= link_to 'Edit', edit_match_path(match) %></td> <td><%= link_to 'Destroy', match, method: :delete, data: { confirm: 'Are you sure?' } %></td> diff --git a/app/views/matches/index.json.jbuilder b/app/views/matches/index.json.jbuilder index 08ae0ef..0b2bfcd 100644 --- a/app/views/matches/index.json.jbuilder +++ b/app/views/matches/index.json.jbuilder @@ -1,4 +1,4 @@ json.array!(@matches) do |match| - json.extract! match, :id, :tournament_id, :name + json.extract! match, :id, :tournament_id, :name, :winner_id json.url match_url(match, format: :json) end diff --git a/app/views/matches/show.html.erb b/app/views/matches/show.html.erb index 0b02ae7..3abb1f7 100644 --- a/app/views/matches/show.html.erb +++ b/app/views/matches/show.html.erb @@ -10,5 +10,10 @@ <%= @match.name %> </p> +<p> + <strong>Winner:</strong> + <%= @match.winner %> +</p> + <%= link_to 'Edit', edit_match_path(@match) %> | <%= link_to 'Back', matches_path %> diff --git a/app/views/matches/show.json.jbuilder b/app/views/matches/show.json.jbuilder index 128550f..fe14010 100644 --- a/app/views/matches/show.json.jbuilder +++ b/app/views/matches/show.json.jbuilder @@ -1 +1 @@ -json.extract! @match, :id, :tournament_id, :name, :created_at, :updated_at +json.extract! @match, :id, :tournament_id, :name, :winner_id, :created_at, :updated_at |