Move populating the match below to when the state is changed

This commit is contained in:
Daniel Schädler 2019-05-13 11:04:44 +02:00
parent 7a9da4e22d
commit 2b39bb1521
1 changed files with 7 additions and 7 deletions

View File

@ -13,6 +13,7 @@ class MatchesController < ApplicationController
# PATCH/PUT /matches/1
def update
new_state = match_params['state']
if @match.update(match_params)
if new_state == 'finished'
result = PopulateMatchBelowAndSave.call(match: @match) unless @match.group_match?
unless result.success?
@ -20,7 +21,6 @@ class MatchesController < ApplicationController
return
end
end
if @match.update(match_params)
render json: @match
else
render json: @match.errors, status: :unprocessable_entity