Rails 3.1 link_to not showing confirmation or destroying properly

后端 未结 2 772
旧巷少年郎
旧巷少年郎 2021-01-20 01:22

I\'ve been plowing through the chapters at railstutorial.org and been using Rails 3.1.3 because I\'m crazy and/or wanted a challenge. I managed to figure out most version pr

2条回答
  •  我在风中等你
    2021-01-20 02:06

    The a HTML tag will always fire the GET method. Rails uses the Javascript driver to replace the HTTP verb. The link_to method will fallback any method (post, put and delete) to get (corresponding to the show action) when :

    • Javascript has been disabled by the user
    • for some reason, Rails unobtrusive javascript driver is not handling the link properly

    See http://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html

    I suspect the second reason to be the issue. Make sure the jquery.js, application.js, jquery_ujs.js file are included.

    Instead of link_to, you could try to use button_to which creates a form allowing put, post and delete methods without Javascript enabled.

提交回复
热议问题