1

I want to call a Rails method from a JavaScript method using AJAX. Please help me.

John Topley
  • 113,588
  • 46
  • 195
  • 237
manish nautiyal
  • 2,556
  • 3
  • 27
  • 34

2 Answers2

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

Community
  • 1
  • 1
bnaul
  • 17,288
  • 4
  • 32
  • 30
-1
John Topley
  • 113,588
  • 46
  • 195
  • 237