class Admin::PayoutsController < ApplicationController before_action :authenticate_user! before_action :ensure_admin! def index @payouts = Payout.includes(:event, :user) .order(created_at: :desc) .page(params[:page]) end def create @payout = Payout.find(params[:id]) begin @payout.process_payout! redirect_to admin_payouts_path, notice: "Payout processed successfully." rescue => e redirect_to admin_payouts_path, alert: "Failed to process payout: #{e.message}" end end private def ensure_admin! # For now, we'll just check if the user has a stripe account # In a real app, you'd have an admin role check unless current_user.has_stripe_account? redirect_to dashboard_path, alert: "Access denied." end end end