https://ruby-doc.org/stdlib-2.1.1/libdoc/date/rdoc/Date.html#method-c-today
Date.today is a ruby core class and method which creates a date object of the current date.
Great topic. Will add to my TODO list.
Can you post the JS and Routes file?
With a nested routes like that,
get_barcode_ticket_orders POST /tickets/:ticket_id/orders/get_barcode(.:format) orders#get_barcode
You would need to also pass the parameter ticket_id into the data hash. Is the ticket_id available at this point? If so, you could pass it into a data attribute and access it in the JS. Otherwise, you may want to reconsider the routes to look something like this (or similar):
resources :tickets do
resources :orders
end
post '/orders/get_barcode', as: :get_barcode, controller: :orders, action: :get_barcode
# get_barcode POST /orders/get_barcode(.:format) orders#get_barcode
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 }