Why Rails “link_to” does not work for delete action?

后端 未结 4 1570
礼貌的吻别
礼貌的吻别 2020-12-16 21:17

In index.html.erb I display all products, and next to each product I have Edit and Delete actions:

<% @products.eac         


        
相关标签:
4条回答
  • 2020-12-16 21:27

    Do you have rails.js specified in a javascript_include_tag? This is required for the unobtrusive DELETE method to work. If you're using jQuery then there's a solution for that too.

    0 讨论(0)
  • 2020-12-16 21:43

    I had same problem - actually I had changed my old 'delete' action to 'destroy' - but forgot If your using SSL.. (e.g ssl_required :destroy)

    0 讨论(0)
  • 2020-12-16 21:47

    It needs to be product_path(product) instead of product in your delete link.

    0 讨论(0)
  • 2020-12-16 21:52

    Dont forget to include jquery_ujs in your application.js file:

    //
    //= require jquery
    //= require jquery_ujs
    // ...
    
    0 讨论(0)
提交回复
热议问题