# How to delete a specific frame?

**URL:** <https://discuss.hotwired.dev/t/how-to-delete-a-specific-frame/4130>\
**Category:** General\
**Created:** [May 18, 2022, 4:25am UTC](https://discuss.hotwired.dev/t/how-to-delete-a-specific-frame/4130 "2022-05-18T04:25:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![evgenyneu](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/evgenyneu/32/2735_2.png) [@evgenyneu](https://discuss.hotwired.dev/u/evgenyneu)\
**Post date:** [May 18, 2022, 4:25am UTC](https://discuss.hotwired.dev/t/how-to-delete-a-specific-frame/4130/1 "2022-05-18T04:25:31Z")

</div>

I’m using Rails 7 with `turbo-rails` gem and output the following HTML containing the list of messages with delete links:

```auto
<turbo-frame id="message_1">
    <h1>Title 1</h1>
    <a href="/messages/1" data-turbo-method="delete">Delete</a>
</turbo-frame>

<turbo-frame id="message_2">
    <h1>Title 2</h1>
    <a href="/messages/2" data-turbo-method="delete">Delete</a>
</turbo-frame>

```

When user clicks the delete button I want the corresponding message

1. to be deleted from the database
2. to be removed from the screen by removing its turbo frame.

without full page reload. I do delete the message from the database in the `MessageController#destroy` action. However, the message is not removed from the screen (until I manually refresh the page).

What should I render in the `MessageController#destroy` action to remove the message from the screen?

---

<div class="post-metadata">

**Author:** ![yunggindigo](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/yunggindigo/32/1271_2.png) [@yunggindigo](https://discuss.hotwired.dev/u/yunggindigo)\
**Post date:** [May 18, 2022, 5:00pm UTC](https://discuss.hotwired.dev/t/how-to-delete-a-specific-frame/4130/2 "2022-05-18T17:00:47Z")

</div>

```auto
def destroy
  if @message.destroy!
    render turbo_stream: turbo_stream.remove("message_#{@message.id")
  end
end

```

---

<div class="post-metadata">

**Author:** ![evgenyneu](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/evgenyneu/32/2735_2.png) [@evgenyneu](https://discuss.hotwired.dev/u/evgenyneu)\
**Post date:** [May 18, 2022, 8:35pm UTC](https://discuss.hotwired.dev/t/how-to-delete-a-specific-frame/4130/3 "2022-05-18T20:35:14Z")

</div>

[yunggindigo](https://discuss.hotwired.dev/u/yunggindigo) Is it possible to do this without turbo streams? I’m currently not using them.

---

<div class="post-metadata">

**Author:** ![tleish](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/tleish/32/920_2.png) [@tleish](https://discuss.hotwired.dev/u/tleish)\
**Post date:** [May 18, 2022, 10:10pm UTC](https://discuss.hotwired.dev/t/how-to-delete-a-specific-frame/4130/4 "2022-05-18T22:10:29Z")

</div>

> [@evgenyneu](#):
>
> I’m currently not using them.

You don’t need to use web sockets to use turbo-stream.

> [@TIP: Turbo-stream with HTTP Responses (including GET)](https://discuss.hotwired.dev/t/tip-turbo-stream-with-http-responses-including-get/3393):
>
> Many incorrectly believe that turbo-streams only work with WebSockets. The [Turbo Handbook - Streaming from HTTP Responses](https://turbo.hotwired.dev/handbook/streams#streaming-from-http-responses) explains how to use turbo-streams with non-GET requests. We’ve discovered it’s possible to also use turbo-streams with GET requests using turbo-frames. We use this technique for pagination. The following table might help explain how. 1. Turbo sends a fetch request to the server with: ...`POST`, `PUT`, `PATCH`, or `DELETE` ...turbo-frame `GET`. …

---

<div class="post-metadata">

**Author:** ![evgenyneu](https://yyz1.discourse-cdn.com/flex027/user_avatar/discuss.hotwired.dev/evgenyneu/32/2735_2.png) [@evgenyneu](https://discuss.hotwired.dev/u/evgenyneu)\
**Post date:** [May 18, 2022, 11:40pm UTC](https://discuss.hotwired.dev/t/how-to-delete-a-specific-frame/4130/5 "2022-05-18T23:40:26Z")

</div>

> You don’t need to use web sockets to use turbo-stream.

Oh, I did not know that, thanks! [yunggindigo](https://discuss.hotwired.dev/u/yunggindigo)’s solution works perfectly without any web sockets.
