Associate teams only on interactor success
This commit is contained in:
parent
3109308817
commit
2baefb9ae6
|
|
@ -39,10 +39,10 @@ class TournamentsController < ApplicationController
|
|||
if group_stage
|
||||
params.require(:playoff_teams_amount)
|
||||
groups = organize_teams_in_groups(teams)
|
||||
# associate provided teams with tournament
|
||||
tournament.teams = groups.flatten
|
||||
# add groups to tournament
|
||||
result = AddGroupStageToTournamentAndSave.call(tournament: tournament, groups: groups)
|
||||
# associate provided teams with tournament on success
|
||||
tournament.teams = groups.flatten if result.success?
|
||||
else
|
||||
# convert teams parameter into Team objects
|
||||
teams = teams.map(&method(:find_or_create_team))
|
||||
|
|
|
|||
Loading…
Reference in New Issue