refactor: BoardAccessible concernを導入し、ボード関連コントローラを整理、ターン表示ロジックをTurnモデルへ移動し、ボード提案表示をコントローラで処理するよう変更
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
class BoardPostsController < ApplicationController
|
||||
include BoardAccessible
|
||||
|
||||
before_action :require_login
|
||||
before_action :set_game
|
||||
before_action :set_board
|
||||
@@ -13,11 +15,9 @@ class BoardPostsController < ApplicationController
|
||||
@post = @board.board_posts.new(post_params)
|
||||
@post.participant = @current_participant
|
||||
|
||||
# フェーズ情報の付与
|
||||
# 最新のターン情報を取得してセットする
|
||||
latest_turn = @game.turns.order(number: :desc).first
|
||||
if latest_turn
|
||||
@post.phase = latest_turn.phase
|
||||
# フェーズ情報の付与(latest_turnアソシエーションを使用)
|
||||
if @game.latest_turn
|
||||
@post.phase = @game.latest_turn.phase
|
||||
end
|
||||
|
||||
if @post.save
|
||||
@@ -29,18 +29,6 @@ class BoardPostsController < ApplicationController
|
||||
|
||||
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
|
||||
|
||||
def post_params
|
||||
params.require(:board_post).permit(:body)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user