このコミットが含まれているのは:
2026-06-08 08:45:52 +09:00
コミット fb2b2a632c
4個のファイルの変更33行の追加11行の削除
+11 -5
ファイルの表示
@@ -2,16 +2,22 @@ class GekanatorGamesController < ApplicationController
def create
return head :unauthorized unless current_user
guessed_post_id = params.require(:guessed_post_id)
correct_post_id = params[:correct_post_id].presence
answers = params.require(:answers).as_json
game = GekanatorGame.create!(
game = GekanatorGame.new(
user: current_user,
guessed_post_id: params.require(:guessed_post_id),
correct_post_id: params[:correct_post_id].presence,
won: params[:guessed_post_id].to_i == params[:correct_post_id].to_i,
guessed_post_id:,
correct_post_id:,
won: correct_post_id.present? && guessed_post_id.to_i == correct_post_id.to_i,
question_count: params.require(:question_count),
answers:)
render json: { id: game.id }, status: :created
if game.save
render json: { id: game.id }, status: :created
else
render json: { errors: game.errors.full_messages }, status: :unprocessable_entity
end
end
end