このコミットが含まれているのは:
2025-08-11 06:10:19 +09:00
コミット 5239dc5967
4個のファイルの変更344行の追加80行の削除
+9
ファイルの表示
@@ -2,7 +2,16 @@ class Post < ApplicationRecord
belongs_to :thread, class_name: 'Topic', foreign_key: :thread_id
has_one_attached :image
before_create :set_post_no
has_secure_password validations: false
scope :active, -> { where deleted_at: nil }
private
def set_post_no
max_no = Post.where(thread_id:).maximum(:post_no) || 0
self.post_no = max_no + 1
end
end