Start your All-Access Pass to unlock this challenge
Following up with my chat message test, I came up with the right stream template to add the new messages to our users chat log.
<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>
Now, whenever a user submits the form to send a message, I'd like to return an empty form to reset the user's chat and stream the new messages to all chatrooms.
What would the code for this action look like?