title: How to call confirm prompt using button_to in Rails with Turbo
body: <p>Previously in Rails when using the <code>button_to</code> tag, it was possible to use a confirmation dialog like this</p>
  <pre><code>&lt;%= button_to 'Destroy', @post, method: :delete, data: { confirm: 'Are you sure?' } %&gt;
  </code></pre>
  <p><code>data: { confirm: 'Are you sure?' }</code> is Rails magic data attribute that  was used by @rails/ujs library under the hood</p>
  <p>Following Rails 7, this library is no longer on by default. Instead of this Rails use Turbo library</p>
  <p>And now this code does not work</p>
  <p>There is no information in official <a href="https://api.rubyonrails.org/v7.0.1/classes/ActionView/Helpers/UrlHelper.html#method-i-button_to" rel="noreferrer">Rails docs</a> and <a href="https://turbo.hotwired.dev/handbook/introduction" rel="noreferrer">Turbo handbook</a></p>
  <p>What I tried</p>
  <pre><code>&lt;%= button_to 'Destroy', @post, method: :delete, data: { turbo_confirm: 'Are you sure?' } %&gt;
  &lt;%= button_to 'Destroy', @post, method: :delete, data: { 'turbo-confirm': 'Are you sure?' } %&gt;
  </code></pre>
  <p>But there is no result</p>
  <p>I didn't find any solution on SO but found on Hotwire <a href="https://discuss.hotwired.dev/t/button-to-not-showing-the-data-confirm/2046" rel="noreferrer">forum</a>. This solution with Stimulus action. I just improve it a little</p>
  <pre><code>&lt;%= form_with model: @post, method: :delete, data: { controller:  'confirmation', message: 'Are you sure?', action: 'submit-&gt;confirmation#confirm' } do |f| %&gt;
    &lt;%= f.submit 'Destroy' %&gt;
  &lt;% end %&gt;
  </code></pre>
  <pre><code>// app/javascript/confirmation_controller.js
  import { Controller } from '@hotwired/stimulus'
  
  export default class extends Controller {
    confirm(event) {
      if (!(window.confirm(this.element.dataset.message))) {
        event.preventDefault()
      }
    }
  }
  </code></pre>
  <p>It works but it's quite difficult and looks ugly, and we are used to Rails being cool</p>