ruby on rails link_to delete method not working

后端 未结 7 1495
挽巷
挽巷 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:34

    Make sure that there is no space after the param

    def destroy
            @post = Post.find(params[:id])
            @post.destroy
            redirect_to posts_path, :notice => "Your post has been deleted successfully."
    end
    

提交回复
热议问题