From f2dfb123e0f8fd347c52b0592638154a999d40d8 Mon Sep 17 00:00:00 2001 From: Malaber <32635600+Malaber@users.noreply.github.com> Date: Thu, 11 Apr 2019 15:09:32 +0200 Subject: [PATCH] Check whether a key exists correctly --- app/controllers/tournaments_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/tournaments_controller.rb b/app/controllers/tournaments_controller.rb index 94e98c0..aaf9914 100644 --- a/app/controllers/tournaments_controller.rb +++ b/app/controllers/tournaments_controller.rb @@ -23,9 +23,9 @@ class TournamentsController < ApplicationController params.require(:teams) # convert teams parameter into Team objects teams = params.delete('teams').map do |team| - if team[:id] + if team.key? 'id' Team.find team[:id] - elsif team[:name] + elsif team.key? 'name' Team.create name: team[:name] end end