diff options
-rw-r--r-- | app/controllers/matches_controller.rb | 8 | ||||
-rw-r--r-- | app/models/match.rb | 1 | ||||
-rw-r--r-- | app/views/matches/_form.html.erb | 15 | ||||
-rw-r--r-- | app/views/matches/index.html.erb | 2 | ||||
-rw-r--r-- | app/views/matches/new.html.erb | 2 | ||||
-rw-r--r-- | config/routes.rb | 10 |
6 files changed, 13 insertions, 25 deletions
diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index 984be3f..2d8ea5e 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -1,10 +1,10 @@ class MatchesController < ApplicationController - before_action :set_match, only: [:show, :edit, :update, :destroy] + before_action :set_match #, only: [:show, :edit, :update, :destroy] # GET /matches # GET /matches.json def index - @matches = Match.all + @matches = @tournament.matches end # GET /matches/1 @@ -14,7 +14,7 @@ class MatchesController < ApplicationController # GET /matches/new def new - @match = Match.new + end # GET /matches/1/edit @@ -64,7 +64,7 @@ class MatchesController < ApplicationController private # Use callbacks to share common setup or constraints between actions. def set_match - @match = Match.find(params[:id]) + @tournament = Tournament.find(params[:tournament_id]) end # Never trust parameters from the scary internet, only allow the white list through. diff --git a/app/models/match.rb b/app/models/match.rb index 533435a..8acebf7 100644 --- a/app/models/match.rb +++ b/app/models/match.rb @@ -1,3 +1,4 @@ class Match < ActiveRecord::Base belongs_to :tournament + end diff --git a/app/views/matches/_form.html.erb b/app/views/matches/_form.html.erb index c5f1ba8..015aed0 100644 --- a/app/views/matches/_form.html.erb +++ b/app/views/matches/_form.html.erb @@ -1,16 +1,5 @@ -<%= form_for(@match) do |f| %> - <% if @match.errors.any? %> - <div id="error_explanation"> - <h2><%= pluralize(@match.errors.count, "error") %> prohibited this match from being saved:</h2> - - <ul> - <% @match.errors.full_messages.each do |msg| %> - <li><%= msg %></li> - <% end %> - </ul> - </div> - <% end %> - +<%= form_for([@tournament, @tournament.matches.build]) do |f| %> + <div class="field"> <%= f.label :tournament_id %><br> <%= f.text_field :tournament_id %> diff --git a/app/views/matches/index.html.erb b/app/views/matches/index.html.erb index 0742770..d258638 100644 --- a/app/views/matches/index.html.erb +++ b/app/views/matches/index.html.erb @@ -26,4 +26,4 @@ <br> -<%= link_to 'New Match', new_match_path %> +<%= link_to 'New Match', new_tournament_match_path %> diff --git a/app/views/matches/new.html.erb b/app/views/matches/new.html.erb index bd4c78c..9ac669f 100644 --- a/app/views/matches/new.html.erb +++ b/app/views/matches/new.html.erb @@ -2,4 +2,4 @@ <%= render 'form' %> -<%= link_to 'Back', matches_path %> + diff --git a/config/routes.rb b/config/routes.rb index 2409eb2..72445c8 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -13,12 +13,10 @@ Leaguer::Application.routes.draw do resources :teams - resources :matches - - resources :tournaments - - #set 'selected' to: 'tournaments#selected' via: 'get' - + resources :tournaments do + resources :matches + end + resources :servers root to: 'static#homepage' |