Dan Tappin
Dan Tappin

Reputation: 3032

Turbo broadcast_append_later_to / broadcast_append_later rendering twice

I the top of my application template body I have:

<%= turbo_frame_tag :toasts %>

Which I use to display messages (https://github.com/excid3/tailwindcss-stimulus-components)

In my controllers I have an update_index patch route so that I can do some updates from the index page. The controller and corresponding turbo rendering works on the UI. In that update_index controller action I have this:

@project.broadcast_append_later_to @project, target: 'toasts', partial: 'shared/toast', locals: { user: current_user, type: :notice, message: "Project #{@project.name} Updated" }

In this action (for context is it matters this was the first model I added to my app). When I update via that action the toast is displayed as expected. The crazy part here is if I add this same logic to my other models the toast gets appended TWICE every-time.

Some context to perhaps trigger ideas:

This seems like a wild goosechase and looking for help - perhaps someone may be able to point me to something obvious I am missing here.

Upvotes: 1

Views: 1772

Answers (1)

Dan Tappin
Dan Tappin

Reputation: 3032

This happens when you add a turbo_stream_from tag twice 🤦‍♂️

Upvotes: 3

Related Questions