dawarich/app/models/export.rb

20 lines
398 B
Ruby
Raw Normal View History

2024-06-12 14:29:38 -04:00
# frozen_string_literal: true
class Export < ApplicationRecord
belongs_to :user
2024-09-05 15:01:59 -04:00
enum :status, { created: 0, processing: 1, completed: 2, failed: 3 }
2024-06-12 14:29:38 -04:00
validates :name, presence: true
before_destroy :delete_export_file
private
def delete_export_file
file_path = Rails.root.join('public', 'exports', "#{name}.json")
File.delete(file_path) if File.exist?(file_path)
end
end