Rails 3 :method=> :delete doesn't work in Internet Explorer

前端 未结 11 860
天涯浪人
天涯浪人 2020-12-09 00:44

I am going through the rails 3 tutorial at railstutorial.org. I have just created an extremely simple scaffold Users.

The scaffold-generated destroy link does not wo

相关标签:
11条回答
  • 2020-12-09 01:04

    I experience the same problem, regardless of web browser.

    theschmitzer's answer didn't help me.

    I found that as long as I am using the jquery javascript library the destroy method in the controller is never called.

    In my case I had a conflict between the javascript libraries (jQuery and Prototype) which was hard to figure out for such a newbie. I changed completely to jQuery - as in the end of this railcast: http://railscasts.com/episodes/205-unobtrusive-javascript

    0 讨论(0)
  • 2020-12-09 01:05

    Try replacing your javascript default include with:

    <%= javascript_include_tag "jquery" %>
    <%= javascript_include_tag "jquery.min" %>
    <%= javascript_include_tag "rails" %>
    

    after following the steps above to get the latest jquery.js, jquery.min.js, and rails.js. That worked for me, anyway.

    Or, replace the meaning of :defaults in application.rb:

    config.action_view.javascript_expansions[:defaults] = %w(jquery jquery.min rails)
    

    And then your application layout can still look have

        <%= javascript_include_tag :defaults %>
    
    0 讨论(0)
  • 2020-12-09 01:06

    I had the same problem. I was using the <%= javascript_include_tag :defaults %> as well as the jQuery library. When I removed the jQuery library, things worked. Also, you could use noConflict().

    0 讨论(0)
  • 2020-12-09 01:09

    In Rails 3.1 with the asset pipeline, all the javascript is in application.js. So, rather than :defaults, you need "application".

    <%= javascript_include_tag "application" %>
    
    0 讨论(0)
  • 2020-12-09 01:12

    I notice that in rails 4, link_to puts the :method as a html attribute "data-method" but :confirm goes to an attribute "confirm" where the javascript needs it to be "data-confirm".

    Not sure if this is a bug in rails, but you can work around it by doing this:

    <%= link_to 'Destroy', user, :data => {:confirm => 'Are you sure?'}, :method => :delete %>
    
    0 讨论(0)
提交回复
热议问题