This commit is contained in:
2026-04-09 23:33:18 +09:00
parent b2d72ffcb0
commit 625507abf6
4 changed files with 83 additions and 61 deletions
+5 -2
View File
@@ -11,9 +11,12 @@ class PostVersion < ApplicationRecord
belongs_to :parent, class_name: 'Post', optional: true
belongs_to :created_by_user, class_name: 'User', optional: true
enum :event_type, create: 'create', update: 'update', discard: 'discard', restore: 'restore'
enum :event_type, { create: 'create',
update: 'update',
discard: 'discard',
restore: 'restore' }, prefix: true, validate: true
validates :version_no, presence: true, numerically: { only_integer: true, greater_than: 0 }
validates :version_no, presence: true, numericality: { only_integer: true, greater_than: 0 }
validates :event_type, presence: true, inclusion: { in: event_types.keys }
validates :url, presence: true
@@ -3,7 +3,7 @@ class PostVersionRecorder
new(post:, event_type:, created_by_user:).record!
end
def initialize post:, event_type:, created_user:
def initialize post:, event_type:, created_by_user:
@post = post
@event_type = event_type
@created_by_user = created_by_user
@@ -23,7 +23,7 @@ class PostVersionRecorder
title: attrs[:title],
url: attrs[:url],
thumbnail_base: attrs[:thumbnail_base],
tags: attrs[:url],
tags: attrs[:tags],
parent: attrs[:parent],
original_created_from: attrs[:original_created_from],
original_created_before: attrs[:original_created_before],