# Destroy record in turbo-frame

**URL:** <https://discuss.hotwired.dev/t/destroy-record-in-turbo-frame/2731>\
**Category:** General\
**Created:** [April 20, 2021, 4:17pm UTC](https://discuss.hotwired.dev/t/destroy-record-in-turbo-frame/2731 "2021-04-20T16:17:19Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![dan](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/dan/32/1529_2.png) [@dan](https://discuss.hotwired.dev/u/dan)\
**Post date:** [May 16, 2021, 2:00pm UTC](https://discuss.hotwired.dev/t/destroy-record-in-turbo-frame/2731/8 "2021-05-16T14:00:34Z")

</div>

@julian from a more conceptual point of view…the answer is it’s just what the web wants us to do. HTML doesn’t natively give us a way for a link to make a POST request, because that’s not what a link is for! The HTML standard [says a link is for navigation](https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element). When you navigate around the web, you make a series of GET requests. Navigation doesn’t imply you want to _do_ anything while there. Per the HTML standard: “These are links to other resources that are generally exposed…so that the user can cause the user agent to [navigate](https://html.spec.whatwg.org/multipage/browsing-the-web.html#navigate) to those resources, e.g. to visit them in a browser or download them.” And that’s why a link will always make a GET request. A GET request is a visit, it says “show me this” and it’s idempotent. When you make the same request it’ll show the same thing.

I think it’s actually semantically incorrect for a link to be anything other than a GET. That’d imply a side-effect (and that, of course, is exactly what you want ujs to do). HTML’s answer for making a request to _do_ something (cause a side effect) is a form.

Now, I understand someone might think this is all a bit academic. We style links to look buttons and sometimes buttons to look like links. It is academic. But it’s analgous to believing, say, a query method in Ruby — `def valid?` or something else that ends in a ? — shouldn’t have side effects.

@pgr Presumably you can’t do this:

```auto
<%= form_with model: @model do |form| %>
<%# some form %>
<% end %>

<%= button_to "Delete", @model, method: :delete %>

```

(maybe with a wrapper `<div>` or something)? Is that because your button is somewhere in the midde of the form?

If so, you could try putting [`formmethod` and `formaction` attributes](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/submit#additional_attributes) on a submit input inside your form. Those will override the `action` and `method` on the parent form, but only when it’s submitted using that input

---

_[View the full topic](https://discuss.hotwired.dev/t/destroy-record-in-turbo-frame/2731)._
