1

I ran into a previous question here: Delete link sends "Get" instead of "Delete" in Rails 3 view where the top rated answer states that you need the following code in your head section in order for link_to to function properly with a DELETE verb:

<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>

From what I can tell my code is working fine without those headers. Are they necessary? I'm running rails 3.1.1. Using gems formtastic 2.0.2, devise 1.5.1, and the latest version of whenever. Thanks.

Community
  • 1
  • 1
Steve
  • 4,446
  • 7
  • 35
  • 50
  • Do you have another header instead? Like `javascript_include_tag 'application'`? – Sergio Tulentsev Dec 31 '11 at 08:02
  • What does it mean? Can you look at generated page then? – Sergio Tulentsev Dec 31 '11 at 08:08
  • Yes I can look at the generated page and the row in the database gets deleted. Could one of my gems maybe be doing this for me? – Steve Dec 31 '11 at 08:10
  • 1
    You still need `javascript_include_tag "application"` in 3.1.1, I believe. Try disabling javascript in your browser - then the delete might no longer work. That will help you narrow down whether javascript is indeed needed or some other gem is doing some magic for you. – Zabba Dec 31 '11 at 08:11
  • 1
    @Steve: look at generated page's source. What's there in the ``? – Sergio Tulentsev Dec 31 '11 at 08:13
  • I couldn't find it because I was looking at an older version of my code. Bad mistake sorry yes it's in there. Thanks for the help. – Steve Dec 31 '11 at 08:14

1 Answers1

-1

If you want you use a confirmation dialogue on your delete link, then yes you need it.

However, in Rails 3, it uses new HTML 5 conventions of custom attributes and in links, creates a "data-method" attribute which then adopts "puts" etc. based on your action chosen. This attribute is then read by Rails and the appropriate controller action is determined.

So in short: no, you do not need the JQuery framework for basic delete links.

Supy
  • 180
  • 2
  • 10