Files
fizzy/app/controllers/account/exports_controller.rb
T
Kevin McConnell 2c1ab1bb29 Formatting
2025-12-01 17:19:59 +00:00

24 lines
683 B
Ruby

class Account::ExportsController < ApplicationController
before_action :ensure_export_limit_not_exceeded, only: :create
before_action :set_export, only: :show
CURRENT_EXPORT_LIMIT = 10
def show
end
def create
Current.account.exports.create!(user: Current.user).build_later
redirect_to account_settings_path, notice: "Export started. You'll receive an email when it's ready."
end
private
def ensure_export_limit_not_exceeded
head :too_many_requests if Current.user.exports.current.count >= CURRENT_EXPORT_LIMIT
end
def set_export
@export = Current.account.exports.completed.find_by(id: params[:id], user: Current.user)
end
end