Tuesday, July 26, 2011

link_to data-method delete not working in IE9?

I was testing a Ruby on Rails 3 application with devise authentication library and to my surprise, link_to with data-method was not working in Internet Explorer 9 (IE9). In that case, the method was set to delete. It works perfectly in Chrome, though.

There are some bugs reported on that, but the solution I found was
  1. Make my application depend on jquery
    • Edit your Gemfile and add:
      • gem 'jquery-rails', '>= 1.0.12'
  2. Run rails generate to install jquery and get rid of other .js files (like prototype.js)
    • rails generate jquery:install
  3. Run application
I did not see these instructions anywhere, just decided to follow what I had done in another project to test Ajax support for Ruby and it just worked. I hope it works for you.

By the way, I've seen several mentions of this, but since my Rails 3 already had it, I did not bother much. In your case, also make sure that your application.html.erb has these tags in your :

<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
Post a Comment