Files
kondiplo_front/app/controllers/board_posts_controller.rb
kontei e90ea88758
Some checks failed
CI / scan_ruby (push) Has been cancelled
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / test (push) Has been cancelled
CI / system-test (push) Has been cancelled
refactor: BoardAccessible concernを導入し、ボード関連コントローラを整理、ターン表示ロジックをTurnモデルへ移動し、ボード提案表示をコントローラで処理するよう変更
2026-02-19 22:46:24 +09:00

36 lines
1002 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
class BoardPostsController < ApplicationController
include BoardAccessible
before_action :require_login
before_action :set_game
before_action :set_board
before_action :set_current_participant
def create
# 参加チェック
unless @board.member?(@current_participant) && @game.status == "in_progress"
return redirect_to game_board_path(@game, @board), alert: "投稿権限がありません"
end
@post = @board.board_posts.new(post_params)
@post.participant = @current_participant
# フェーズ情報の付与latest_turnアソシエーションを使用
if @game.latest_turn
@post.phase = @game.latest_turn.phase
end
if @post.save
redirect_to game_board_path(@game, @board) # noticeはチャット的にうるさいので省略
else
redirect_to game_board_path(@game, @board), alert: "投稿に失敗しました"
end
end
private
def post_params
params.require(:board_post).permit(:body)
end
end