Rails form_for :remote=>true is not calling js method

When you check the request made in firebug, just because the url did not end with .js, it does not mean that it was not called from javascript. To verify that you should check the request header to see what the Accept parameter is. If it says “application/javascript” then it’s all good.

Secondly, a very common problem when starting to try out the :remote => true is that the required javascript libraries are not included in your code. So my guess is that the following code is missing from your layout:

<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>

If that is the case, just include it inside the <head> tag of your layout.

Leave a Comment