Delete / Destroy is not working in rails 3 with jQuery

后端 未结 4 1250
长情又很酷
长情又很酷 2020-12-10 07:25

My delete/destroy is not working for Rails 3.

Not for any scaffold or even for new projects.

<%= link_to \'Destroy\', card, :confirm => \'Are y         


        
4条回答
  •  無奈伤痛
    2020-12-10 08:12

    I ran into the same issue Mohit had and also needed to include the 'Unobtrusive JavaScript Library' (or 'ujs') in my JavaScript assets. In my current Rails (v3.2.5), the UJS library will be provided automatically. You can verify this by seeing the following line in your Gemfile:

    gem 'jquery-rails'

    and the following line in your app/assets/javascripts/application.js file:

    //= require jquery_ujs

    Since I didn't know any better, I had removed the require jquery_ujs line from my own application.js file, and it took me a while to figure out why my link_to ..., :method => :delete calls weren't working any more!

    Once I understood the problem, it was easy to add the above two lines back to their respective files and everything started working as expected again.

提交回复
热议问题