scinote-web/app/models/temp_file.rb

20 lines
439 B
Ruby
Raw Normal View History

2019-05-09 23:10:02 +08:00
# frozen_string_literal: true
2017-06-23 21:19:08 +08:00
class TempFile < ApplicationRecord
2016-02-12 23:52:43 +08:00
validates :session_id, presence: true
has_attached_file :file
do_not_validate_attachment_file_type :file
class << self
def destroy_obsolete(temp_file_id)
temp_file = find_by_id(temp_file_id)
return unless temp_file.present?
2019-05-09 23:10:02 +08:00
temp_file.destroy!
end
2019-05-09 23:10:02 +08:00
handle_asynchronously :destroy_obsolete, run_at: proc { 7.days.from_now }
end
2016-02-12 23:52:43 +08:00
end