Files
kondiplo_front/app/models/board_membership.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

22 lines
509 B
Ruby

class BoardMembership < ApplicationRecord
belongs_to :board
belongs_to :participant
# 参加中かどうか(退出していない)
def active?
left_at.nil?
end
# 退出処理
def leave!
update!(left_at: Time.current)
end
# 既読位置を更新
def mark_read!(post_id)
# 既存の既読位置より新しい場合のみ更新(巻き戻り防止)
# ただし今回は単純に最新をセットする形で良い
update!(last_read_post_id: post_id)
end
end