vendredi 8 mai 2015

Rails delete functionality is not working

I am completely new to Ruby On Rails, and going through this guide to build a basic application.

When I am trying to implement the delete functionality as mentioned in the document, I am seeing the show page.

I have below method in my controller:

def destroy
  @article = Article.find(params[:id])
  @article.destroy

  redirect_to articles_path
end

and below line in my page:

<td><%= link_to 'Destroy', article_path(article),
              method: :delete,
              data: { confirm: 'Are you sure?' } %></td>

Now when I click on the link, I am seeing below URL in browser:

http://localhost:3000/articles/1

Now now in this case I am seeing the show screen instead of getting an alert message and then deleting the record from my page.

I have followed this SO post - Rails 4 link_to Destroy not working in Getting Started tutorial

and verified that

//= require jquery
//= require jquery_ujs

elements are there in my application.js

Please tell me where I am doing mistake?

Aucun commentaire:

Enregistrer un commentaire