ファイル
btrc-hub/backend/app/controllers/gekanator_question_suggestions_controller.rb
T
2026-06-09 01:29:43 +09:00

20 行
565 B
Ruby

class GekanatorQuestionSuggestionsController < ApplicationController
def create
return head :not_found unless current_user&.admin?
game = GekanatorGame.find_by(id: params.require(:gekanator_game_id))
return head :not_found unless game
suggestion = GekanatorQuestionSuggestion.new(
gekanator_game: game,
user: current_user,
question_text: params.require(:question_text))
if suggestion.save
render json: { id: suggestion.id }, status: :created
else
render_validation_error suggestion
end
end
end