24 行
601 B
Ruby
24 行
601 B
Ruby
class PostVersion < ApplicationRecord
|
|
include VersionRecord
|
|
|
|
belongs_to :post
|
|
belongs_to :parent, class_name: 'Post', optional: true
|
|
|
|
validates :url, presence: true
|
|
validates :video_ms, numericality: { only_integer: true, greater_than: 0 }, allow_nil: true
|
|
|
|
validate :validate_original_created_range
|
|
|
|
private
|
|
|
|
def validate_original_created_range
|
|
f = original_created_from
|
|
b = original_created_before
|
|
return if f.blank? || b.blank?
|
|
|
|
if f >= b
|
|
errors.add :original_created_before, 'オリジナルの作成日時の順番がをかしぃです.'
|
|
end
|
|
end
|
|
end
|