I thought I had fixed everything and made ready for Rails 3 in my applications. Turns out I was wrong. My wife tells me I’m wrong all the time so I didn’t feel to bad. The first sign was that something bad had happened was that all my delete links stopped working. I found a couple of articles talking about the new unobtrusive javascript in Rails.
I have bits of code that look like this:
<%= link_to 'Delete Thing', @thing, :confirm => 'Are you sure?', :method => :delete %> </pre>
I know the argument that you shouldn't use links for delete. In this case the generated anchor tag won't cause you problems so I don't want to hear any whining:Delete Course </pre>
I included rails.js which will turn those links into DELETE requests for the server. However, I started seeing this error in Firebug on Firefox:document.on is not a function </pre>
I also got this in Google Chrome:Uncaught TypeError: Object #
has no method 'on' </pre></code> Turns out that since I use jQuery I needed to get the rails.js file for jQuery. There's a gem that wraps it up: https://github.com/rails/jquery-ujs You can also just get the javascript and dump it in rails.js: https://github.com/rails/jquery-ujs/raw/master/src/rails.js Now I can be happy again.