I have an ignore button which isn’t picking up the correct link from Rails. When clicked it should send a post request with the link. Something like
https://myurl.co.uk/orders/174/ignore_export_errors
The browser shows no href link being picked up from the form:
<a class="button primary confirm" data-disable-with="Please wait.." data-id="" data-method="post" data-remote="true" href="">ignore</a>
Relevant code snippets below:
Rails
Views
= render layout: 'royal_mail_click_and_drop_apps/section', locals: { id: 'xero_errored_orders', title: 'Export Errors new' } do
.row.column
.record-list.errored_orders
table.sw-table--inner
thead
tr
th style="width: 30px" Ignore
tbody
- @errored_orders.each do |order|
tr.errored_order data-id=order.id
td.text-center
a.sw-input-group__button.ignore data-open="confirm-ignore-export-error" data-href=ignore_export_errors_order_path(order) data-id=order.id
i.sw-icon-eye aria-hidden="true"
span.show-for-sr ignore
Modal
#confirm-ignore-export-error.reveal data-reveal=""
button.sw-modal__close.close-button aria-label="Close modal" data-close="" type="button"
i.sw-icon-forbidden-mark.margin-0 aria-hidden="true"
h1.sw-modal__heading Ignoring Export Error
p.margin-top-2.margin-bottom-1.text-center Are you sure you want to ignore this error?
.text-center
a.button.primary.confirm href="" data-id="" data-remote="true" data-method="post" data-disable-with="Please wait.." ignore
button.button.secondary data-close="" cancel
Logs
Started POST "/xero_apps?business_id=270×tamp=1648723994&signature=09babb280a35f38617fa60dc78
dc175a50575a5bdf5a3aec18292138f2fa28a1" for 172.25.208.1 at 2022-03-31 11:54:09 +0100
Cannot render console from 172.25.208.1! Allowed networks: 127.0.0.1, ::1, 127.0.0.0/127.255.255.2
55
No route matches [POST] "/xero_apps" excluded from capture: DSN not set
ActionController::RoutingError (No route matches [POST] "/xero_apps"):
The thing is I don’t want a post to this route anyway.
JavaScript
$ ->
$('.export-errors .ignore').click ->
$this = $(this)
$('#confirm-ignore-export-error a').attr('href', $this.data('href')).data('id', $this.data('id'))
$('#confirm-ignore-export-error .confirm').on 'ajax:success', ->
orderId = $(this).data('id')
$("tr.errored_order[data-id='#{orderId}']").fadeOut('normal', -> $(this).remove())
$(this).closest('.reveal').foundation('close')
Upon clicking the ignore button I’m expecting the ignore_export_errors action to execute within OrdersController. However no path is being passed to the front-end button.