samedi 20 septembre 2014

How can I pass an id from js to rails when using ajax?


Vote count:

0




How can I call a rail route and pass in an ID from js.


I am switching to using rails routes through my application including in js


I have a call:



# app/assets/javascript/verifying_link.js
$.ajax({
url: "/verify_link/"+id+"&table_row="+row,


but I want to use



# app/assets/javascript/verifying_link.js.erb


but how can I pass the id from js ?


I tried:



url: "<%= Rails.application.routes.url_helpers.verify_link_path(id) %>" + "&table_row="+row,


but I get an error:-



undefined local variable or method `id' for#<#<Class:0x00000001ca3220>:0x007f6228c792f0>
(in /...linker/app/assets/javascript/verifying_link.js.erb)


asked 37 secs ago







How can I pass an id from js to rails when using ajax?

Aucun commentaire:

Enregistrer un commentaire