Filter matches by state parameter

This commit is contained in:
Daniel Schädler 2019-10-26 00:34:04 +02:00
parent 33ccab8988
commit b001817bac
1 changed files with 8 additions and 1 deletions

View File

@ -8,7 +8,14 @@ class MatchesController < ApplicationController
# GET/tournaments/1/matches
def index
render json: @tournament.matches, each_serializer: MatchSerializer
matches = if match_params['state'].nil?
@tournament.matches
else
@tournament.matches.select do |m|
m.state == match_params['state']
end
end
render json: matches, each_serializer: MatchSerializer
end
# GET /matches/1