diff --git a/app/controllers/tickets_controller.rb b/app/controllers/tickets_controller.rb
index a4db9da..931d857 100644
--- a/app/controllers/tickets_controller.rb
+++ b/app/controllers/tickets_controller.rb
@@ -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
diff --git a/app/models/ticket.rb b/app/models/ticket.rb
index a2de92a..51b0ae1 100755
--- a/app/models/ticket.rb
+++ b/app/models/ticket.rb
@@ -70,7 +70,6 @@ class Ticket < ApplicationRecord
self.qr_code = "#{id || 'temp'}-#{Time.current.to_i}-#{SecureRandom.hex(4)}"
end
-
def draft?
status == "draft"
end
diff --git a/app/views/tickets/show.html.erb b/app/views/tickets/show.html.erb
index e315364..0181f79 100644
--- a/app/views/tickets/show.html.erb
+++ b/app/views/tickets/show.html.erb
@@ -131,9 +131,7 @@
-
+
@@ -161,7 +159,7 @@
<% end %>
<% if @ticket.status == 'active' %>
- <%= link_to "#",
+ <%= link_to ticket_download_path(@ticket.qr_code),
class: "flex-1 bg-gradient-to-r from-purple-600 to-indigo-600 hover:from-purple-700 hover:to-indigo-700 text-white font-medium py-3 px-6 rounded-xl shadow-sm transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-purple-500 focus:ring-offset-2 transform hover:-translate-y-0.5 text-center" do %>