SU2-7 | Добавление модели Report с поддержкой загрузки файлов, обновление контроллера и представления для обработки отчетов, а также создание миграций для таблицы отчетов и активного хранилища.

This commit is contained in:
Dmitry
2025-12-10 15:02:39 +03:00
parent ae77bfa911
commit 5f9a4c0da6
8 changed files with 74 additions and 20 deletions
+3 -3
View File
@@ -1,13 +1,13 @@
class ReportsController < ApplicationController
def index
@reports = Report.order(created_at: :desc).limit(10)
end
def create
inn = params[:inn]
output_path = Rails.root.join('tmp', 'reports', inn)
FileUtils.mkdir_p(output_path)
report = Report.create!(inn: inn, status: 'processing')
FileProcessorJob.perform_async(inn, output_path.to_s)
FileProcessorJob.perform_async(inn, report.id)
redirect_to reports_path, notice: 'Отчёт загружается в фоне'
end