I am using Rails and jquery, and I need a dynamic content with ajax.
But I don’t know how to get the current user ID
For example the url is http://www.mywebsite.com/users/20
In my javascript file I need the user ID (20)
$.get("/users/<%= **20** %>.json", function(data)
{
}, "json");
Thanks in advance for any help.
Is there another way to do this ?
You can assign the rails variable value to a javascript variable in your view file like
and access the variable inside js file wherever you want.