Filter matches by state parameter
This commit is contained in:
parent
33ccab8988
commit
b001817bac
|
|
@ -8,7 +8,14 @@ class MatchesController < ApplicationController
|
||||||
|
|
||||||
# GET/tournaments/1/matches
|
# GET/tournaments/1/matches
|
||||||
def index
|
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
|
end
|
||||||
|
|
||||||
# GET /matches/1
|
# GET /matches/1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue