I want to call a Rails method from a JavaScript method using AJAX. Please help me.
Asked
Active
Viewed 805 times
2 Answers
3
You can't exactly "call" a Rails method from the front end. What you can do is have a controller method that renders JSON, and request the URL that routes to that controller method.
Returning JSON is fairly straightforward; you might use something like the syntax in this post: render :json does not accept options