SU2-7 | Добавление модели Report с поддержкой загрузки файлов, обновление контроллера и представления для обработки отчетов, а также создание миграций для таблицы отчетов и активного хранилища.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user