Return matches as children of tournament
This commit is contained in:
parent
77c76b7a31
commit
a6b7a905a0
|
|
@ -4,6 +4,12 @@ class MatchesController < ApplicationController
|
|||
before_action :set_match, only: %i[show update]
|
||||
before_action :validate_params, only: %i[update]
|
||||
before_action -> { require_owner! @match.owner }, only: %i[update]
|
||||
before_action :set_tournament, only: %i[index]
|
||||
|
||||
# GET/tournaments/1/matches
|
||||
def index
|
||||
render json: @tournament.matches, each_serializer: MatchSerializer
|
||||
end
|
||||
|
||||
# GET /matches/1
|
||||
def show
|
||||
|
|
@ -61,6 +67,10 @@ class MatchesController < ApplicationController
|
|||
@match = Match.find(params[:id])
|
||||
end
|
||||
|
||||
def set_tournament
|
||||
@tournament = Tournament.find(params[:tournament_id])
|
||||
end
|
||||
|
||||
def match_params
|
||||
params.slice(:state).permit!
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ Rails.application.routes.draw do
|
|||
resources :teams, only: %i[show update]
|
||||
resources :tournaments do
|
||||
resources :statistics, only: %i[index]
|
||||
resources :matches, only: %i[index]
|
||||
end
|
||||
resources :match_scores, only: %i[show update]
|
||||
resources :groups, only: %i[show]
|
||||
|
|
|
|||
Loading…
Reference in New Issue