Files

18 lines
573 B
Ruby

class ReportsController < ApplicationController
def index
@reports = Report.order(created_at: :desc).limit(10)
end
def create
inn = params[:inn].to_s.strip
unless inn.match?(/\A\d{10}(\d{2})?\z/)
redirect_to reports_path, alert: 'Некорректный ИНН (должен содержать 10 или 12 цифр)'
return
end
report = Report.create!(inn: inn, status: 'processing')
FileProcessorJob.perform_async(inn, report.id)
redirect_to reports_path, notice: 'Отчёт загружается в фоне'
end
end