Fix ticket PDF generation by passing data directly to print_qr_code

This commit is contained in:
kbe
2025-09-05 23:03:50 +02:00
parent a984243fe2
commit 7009245ab0
2 changed files with 11 additions and 5 deletions

View File

@@ -3,7 +3,7 @@
# This controller now primarily handles legacy redirects and backward compatibility
# Most ticket creation functionality has been moved to OrdersController
class TicketsController < ApplicationController
before_action :authenticate_user!, only: [ :payment_success, :payment_cancel ]
before_action :authenticate_user!, only: [ :payment_success, :payment_cancel, :show, :download_ticket ]
before_action :set_event, only: [ :checkout, :retry_payment ]
@@ -49,7 +49,10 @@ class TicketsController < ApplicationController
end
def show
@ticket = current_user.orders.joins(:tickets).find(params[:ticket_id])
@ticket = Ticket.joins(order: :user).includes(:event, :ticket_type, order: :user).find_by(
tickets: { id: params[:ticket_id] },
orders: { user_id: current_user.id }
)
@event = @ticket.event
rescue ActiveRecord::RecordNotFound
redirect_to dashboard_path, alert: "Billet non trouvé"
@@ -58,7 +61,10 @@ class TicketsController < ApplicationController
# Download PDF ticket - only accessible by ticket owner
def download_ticket
# Find ticket and ensure it belongs to current user
@ticket = current_user.orders.joins(:tickets).find_by(tickets: { id: params[:ticket_id] })
@ticket = Ticket.joins(order: :user).includes(:event, :ticket_type, order: :user).find_by(
tickets: { id: params[:ticket_id] },
orders: { user_id: current_user.id }
)
if @ticket.nil?
redirect_to dashboard_path, alert: "Billet non trouvé ou vous n'avez pas l'autorisation d'accéder à ce billet"