Delete method not working in ruby : the destroy method doesn't work but i get redirected to index page but record is not deleted.[enter image description here][1]


HTML.erb link:
<%= link_to "Delete", posts_path(@post), method: :delete, data: {confirm: 'are you sure?'},:class => 'btn btn-danger' %>

Controller:

def destroy
        	@post = Post.find(params[:id])
        	@post.destroy
        	redirect_to posts_path


      


  [1]: https://i.stack.imgur.com/UGqKI.png