雑な実装イメージB
class CardExportingsController <ApplicationController
def index
@card_exports = current_user.card_exportings.all
end
def create
@card_export = CardExporting.new(card_exporting_params)
@card_export.user_id = current_user.id
if @card_export.save
# 非同期処理でcsvのダウンロード準備をする
CardExportingJob.perform_later(@card_export)
redirect_to card_exporting_path(@card_export)
else
render :new
end
end
end
17
18.
雑な非同期処理B
class CardExportingJob <ApplicationJob
def perform(card_export)
data = card_export.to_csv
client = Aws::S3::Client.new
status = client.upload(data) ? :success : :failed
card_export.update(status: status)
end
end
18