The HTML that is rendered seems right:
<a href="/foo/add" data-method="post" data-remote="true" rel="nofollow"><img src=/assets/icons/example.png></a>
Inspite of the data-method and data-remote both being rendered, when I click the link, the browser seems to issue a GET because Rails complains about a lack of a route. I do want this to be a POST but I went ahead and added a GET in routes.rb and the call works but is now is a regular call rather than an AJAX call. I seem to be missing some JS file somewhere… very new to Rails 3.1 – can someone point me in the right direction?
Make sure your
Gemfilehas this:and that your
app/views/layouts/application.html.erbhas this:and that your
app/assets/javascripts/application.jscontains these 2 lines:These parts are all needed to properly use the
:remoteoptions in Rails.