Check whether a key exists correctly
This commit is contained in:
parent
f223c03686
commit
f2dfb123e0
|
|
@ -23,9 +23,9 @@ class TournamentsController < ApplicationController
|
||||||
params.require(:teams)
|
params.require(:teams)
|
||||||
# convert teams parameter into Team objects
|
# convert teams parameter into Team objects
|
||||||
teams = params.delete('teams').map do |team|
|
teams = params.delete('teams').map do |team|
|
||||||
if team[:id]
|
if team.key? 'id'
|
||||||
Team.find team[:id]
|
Team.find team[:id]
|
||||||
elsif team[:name]
|
elsif team.key? 'name'
|
||||||
Team.create name: team[:name]
|
Team.create name: team[:name]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue