blob: e22fa402c75370d4a449afb51207f9bb5fa8fe42 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# == Schema Information
#
# Table name: destructing_statuses
#
# id :bigint(8) not null, primary key
# status_id :bigint(8)
# delete_after :datetime
#
class DestructingStatus < ApplicationRecord
belongs_to :status, inverse_of: :destructing_status
validate :validate_future_date
validates :status_id, uniqueness: true
private
def validate_future_date
errors.add(:delete_after, I18n.t('destructing_statuses.too_soon')) if delete_after.present? && delete_after < Time.now.utc + PostStatusService::MIN_DESTRUCT_OFFSET
end
end
|