class GenerateExportFileJob < ApplicationJob queue_as :default def perform(file_export) Current.user = file_export.exported_by CmCurrent.user_permissions = Current.user.cm_role.cm_permissions if Current.user.cm_role.present? file_export.attach_export_file ExportMailer.export_email(file_export).deliver_now file_export.success! rescue StandardError => e file_export&.failed! raise e end end