掲示板実装
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:30:59 +09:00
parent f25fd6f802
commit bb9ec2df1d
38 changed files with 1711 additions and 13 deletions

View File

@@ -2,6 +2,8 @@ class Game < ApplicationRecord
has_many :turns, dependent: :destroy
has_many :participants, dependent: :destroy
has_many :users, through: :participants
has_many :boards, dependent: :destroy
has_one :latest_turn, -> { order(number: :desc) }, class_name: "Turn"
# パスワード保護
has_secure_password :password, validations: false
@@ -26,6 +28,9 @@ class Game < ApplicationRecord
# ターンスケジュールバリデーション
validate :validate_turn_schedule
# コールバック
after_create :create_global_board
# ヘルパーメソッド
def password_protected?
password_digest.present?
@@ -162,4 +167,8 @@ class Game < ApplicationRecord
errors.add(:turn_schedule, "は0〜23の数値をカンマ区切りで入力してください例: 0,18")
end
end
def create_global_board
boards.create!(board_type: "global", is_public: true)
end
end