feat: Display ticket based on `qr_code` field
- Previously ticket was displayed using id which is too easy to find - Now the URL takes ``qr_code`` field as parameters
This commit is contained in:
@@ -48,11 +48,10 @@ class TicketsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
# Display informations about the event with QR code
|
||||
def show
|
||||
@ticket = Ticket.joins(order: :user).includes(:event, :ticket_type, order: :user).find_by(
|
||||
tickets: { id: params[:ticket_id] },
|
||||
orders: { user_id: current_user.id }
|
||||
)
|
||||
@ticket = Ticket.joins(order: :user).includes(:event, :ticket_type, order: :user)
|
||||
.find_by(tickets: { qr_code: params[:qr_code] })
|
||||
|
||||
if @ticket.nil?
|
||||
redirect_to dashboard_path, alert: "Billet non trouvé"
|
||||
@@ -63,6 +62,7 @@ class TicketsController < ApplicationController
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
redirect_to dashboard_path, alert: "Billet non trouvé"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def set_event
|
||||
|
||||
Reference in New Issue
Block a user