Start your All-Access Pass to unlock this challenge
In my chat application, whenever a user sends a message to the chat, I return a turbo stream message to update all of the user's pages with the new message. My stream code looks like this:
<turbo-stream action="update" id="new-messages-{{ chat.id }}">
<template>
{% for message in chat.newMessages %}
<div class="message">
<span class="user">{{ message.from }}</span>:
{{ message.text }}
</div>
{% endfor %}
</template>
</turbo-stream>
But whenever a user sends a message, the entire chat room disappears and only shows the last messages. Why? And how can I fix it?