diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb index d1d5c61..1465aea 100644 --- a/app/controllers/tickets_controller.rb +++ b/app/controllers/tickets_controller.rb @@ -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" diff --git a/app/services/ticket_pdf_generator.rb b/app/services/ticket_pdf_generator.rb index bd06a6d..219a7db 100755 --- a/app/services/ticket_pdf_generator.rb +++ b/app/services/ticket_pdf_generator.rb @@ -91,8 +91,8 @@ class TicketPdfGenerator raise "QR code data is empty or invalid" end - qrcode = RQRCode::QRCode.new(qr_code_data) - pdf.print_qr_code(qrcode, extent: 120, align: :center) + # Generate QR code - prawn-qrcode expects the data string directly + pdf.print_qr_code(qr_code_data, extent: 120, align: :center) pdf.move_down 15