about summary refs log tree commit diff
path: root/app/models/destructing_status.rb
blob: 349e276cb033704fe938f0d4419ff5851c833d34 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# == 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

  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