module Fileable
  extend ActiveSupport::Concern

  included do
    after_destroy do
      FileUtils.remove_file(file_path) if File.exist?(file_path)
    end
  end

  def file_path
    dir_path.join("#{id}_#{filename}")
  end

  def dir_path
    school.dir_path.join(self.class.table_name)
  end
end
