ruby on rails link_to delete method not working

后端 未结 7 1497
挽巷
挽巷 2021-02-14 06:04

I am trying to delete a post using the code below:

<%= link_to \'Destroy\', post, :method => :delete, :onclick => \"return confirm(\'Are you sure you wa         


        
7条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-14 06:35

    If using link_to with :delete method you must be sure to have javascript active:

    Note that if the user has JavaScript disabled, the request will fall back to using GET.

    As seen in docs

    If you don't want to be dependent on javascript you can use button_to instead of link_to.

提交回复
热议问题