Is there a way to call a rail route and pass in an ID from javascript?
I have recently started using rails routes within my application, even in js.
The current code I am using is:
# app/assets/javascript/verifying_link.js
$.ajax({
url: "/verify_link/"+id+"&table_row="+row,
However, I would like to switch to using:
# app/assets/javascript/verifying_link.js.erb
But I am unsure how to pass the id from javascript. Is there a way to do this?
I attempted the following:
url: "<%= Rails.application.routes.url_helpers.verify_link_path(id) %>" + "&table_row="+row,
Unfortunately, this resulted in an error:-
undefined local variable or method `id' for#<#<Class:0x00000001ca3220>:0x007f6228c792f0>
(in /...linker/app/assets/javascript/verifying_link.js.erb)