refactor: BoardAccessible concernを導入し、ボード関連コントローラを整理、ターン表示ロジックをTurnモデルへ移動し、ボード提案表示をコントローラで処理するよう変更
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

This commit is contained in:
2026-02-19 22:46:24 +09:00
parent bb9ec2df1d
commit e90ea88758
9 changed files with 70 additions and 136 deletions

View File

@@ -1,4 +1,6 @@
class BoardMembershipsController < ApplicationController
include BoardAccessible
before_action :require_login
before_action :set_game
before_action :set_board
@@ -25,11 +27,6 @@ class BoardMembershipsController < ApplicationController
@board.board_memberships.create!(participant_id: target_participant_id, joined_at: Time.current)
end
# メンバー構成が変わったので、他の掲示板と重複していないかチェックが必要だが、
# モデルのバリデーションは「作成時」を想定しているため、ここでは簡易チェックに留めるか、
# あるいはバリデーションエラーをハンドリングする。
# ここではsave成功/失敗で判断
redirect_to game_board_path(@game, @board), notice: "メンバーを追加しました"
rescue ActiveRecord::RecordInvalid => e
redirect_to game_board_path(@game, @board), alert: "メンバー追加に失敗しました: #{e.message}"
@@ -49,18 +46,4 @@ class BoardMembershipsController < ApplicationController
redirect_to game_board_path(@game, @board), alert: "退出に失敗しました"
end
end
private
def set_game
@game = Game.find(params[:game_id])
end
def set_board
@board = @game.boards.find(params[:board_id])
end
def set_current_participant
@current_participant = @game.participants.find_by(user: current_user)
end
end