Ruby on Rails guide DELETE section not working

Viewed 699
<%= link_to "Destroy", article_path(@article), data: {
                turbo_method: :delete,
                turbo_confirm: "Are you sure?"
              } %>

This is listed on the official website of Ruby on Rails as a simple way of deleting an Active Record. I have the same controller method as they do. This does not delete, nor does it confirm. I have found other methods that successfully delete, but none that confirm. I would like to understand why this doesn't delete, and how I can confirm.

3 Answers

This SO post addresses a similar problem and answered by @json fb. Quoting statements from the SO post

This happens if you had locally installed gem versions 7.1.0 or 7.1.1 for turbo-rails

These gem numbers were pushed by accident to Rubygems in October, then yanked. However, since bundler will default to the highest number of your Rails gem when it sets up your new rails app, it will pick turbo-rails version 7.1.0 or 7.1.1 , which will display this flaw

The gems were yanked, so this only affects you if you were developing rails apps between October 2021 and the yank date. TO FIX YOUR COMPUTER: gem uninstall turbo-rails

<ul>
<li><%= link_to "Edit", edit_article_url(@article) %> </li>
<li><%= button_to "Destroy", article_path(@article), method: :delete,
            data: { method_turbo_confirm: "Are you sure?" }
 %></li>

Changing link_to to button_to and adding method: :delete worked for me. Although the "Are you sure?" pop up is still not working.

Related