Since you don't have the ticket_id, it's not a valid route.
In your HTML, if the ticket_id is available and you're already displaying it somewhere then you can create a data attribute like
<%= tag :div, id: 'some_name', data: { 'ticket-id': @ticket.id } %>
You can access the value of the ticket's id in jQuery like
var ticket_id = $('#some_name').data('ticket-id');
And then in the AJAX POST
data: { ticket_id: ticket_id, upc: code }