Files
kondiplo_front/app/models/board_post.rb
kontei bb9ec2df1d
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
掲示板実装
2026-02-19 22:30:59 +09:00

27 lines
629 B
Ruby

class BoardPost < ApplicationRecord
belongs_to :board
belongs_to :participant
validates :body, presence: true
# 作成後にAction Cableで配信
after_create_commit :broadcast_to_board
private
def broadcast_to_board
# ボードごとのチャンネルに配信
ActionCable.server.broadcast(
"board_#{board_id}",
{
post_id: id,
participant_id: participant.id,
power: participant.power, # 国名
body: body,
phase: phase, # フェーズ情報
created_at: created_at.in_time_zone("Asia/Tokyo").strftime("%Y-%m-%d %H:%M")
}
)
end
end