From 4daccc9921a4876da7441eb650f908be67ddd819 Mon Sep 17 00:00:00 2001 From: _Tradam Date: Mon, 17 Jun 2024 00:52:52 -0400 Subject: allow uploading game with no tags --- app/controllers/api/v1/games_controller.rb | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/api/v1/games_controller.rb b/app/controllers/api/v1/games_controller.rb index f40c9de..6a412c8 100644 --- a/app/controllers/api/v1/games_controller.rb +++ b/app/controllers/api/v1/games_controller.rb @@ -16,10 +16,12 @@ class Api::V1::GamesController < ApplicationController @game = user.games.new(game_params.except(:status, :platform_tag)) @game.titleSlug = game_params[:title].parameterize @game.status = game_params[:status].to_i - params["game"]["platform_tag"].each do |tag| - tag_obj = Tag.find_by(tag_type: "platform", name: tag) - if tag_obj - @game.tags << tag_obj + if !params["game"]["platform_tag"].nil? + params["game"]["platform_tag"].each do |tag| + tag_obj = Tag.find_by(tag_type: "platform", name: tag) + if tag_obj + @game.tags << tag_obj + end end end @@ -121,9 +123,9 @@ class Api::V1::GamesController < ApplicationController render html: result.download.html_safe elsif format == "js" render js: result.download.html_safe - #else - # redirect_to url_for(result) - #end + #else + # redirect_to url_for(result) + #end elsif format == "gz" response.headers['Content-Encoding'] = 'gzip' second_ext = filename.rpartition('.').first.rpartition('.').last -- cgit v1.2.3