Note that there are some explanatory texts on larger screens.

plurals
  1. POWhen installing JQuery, why does my "delete" link break?
    primarykey
    data
    text
    <p>I have a Rails 3 application that can create and delete products. An index page lists all the products. Next to each product in the list is a delete link:</p> <pre><code>&lt;%= link_to "Delete", product, :method =&gt; :delete, :title =&gt; "Delete" %&gt; </code></pre> <p>This looks like this in the HTML:</p> <pre><code>&lt;a href="/products/104" data-method="delete" rel="nofollow" title="Delete"&gt;Delete&lt;/a&gt; </code></pre> <p>This has been working fine.</p> <p>I've reached the point where I want to install JQuery in my application. I followed the steps available on several web pages (like <a href="http://lindsaar.net/2010/5/9/Getting-Rails-3-Edge-with-jQuery-RSpec-and-Cucumber-using-RVM" rel="nofollow noreferrer">this</a> or <a href="http://joshhuckabee.com/jquery-rails-3" rel="nofollow noreferrer">this,</a> for example).</p> <p>After installing JQuery, the above "delete" link breaks. Instead of processing the <code>destroy</code> action in <code>ProductsController</code>, Rails attempts to process the <code>show</code> action!</p> <p>My guess is that it has something to do with the fact that web browsers can’t send <code>DELETE</code> requests natively, so Rails "fakes" such requests with JavaScript, which is why I had the following line <em>before</em> attempting the JQuery install:</p> <pre><code>&lt;%= javascript_include_tag :defaults %&gt; </code></pre> <p>Edit: Something during the JQuery install must have made it such that the Javascript used to "fake" the <code>DELETE</code> request no longer works, resulting in the <code>show</code> action being called. But what exactly is happening I don't know...</p> <p>Anyone have any ideas? Thank you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload