Method: Turbo::Broadcastable#broadcast_replace_to
- Defined in:
- app/models/concerns/turbo/broadcastable.rb
#broadcast_replace_to(*streamables, **rendering) ⇒ Object
Replace this broadcastable model in the dom for subscribers of the stream name identified by the passed streamables. The rendering parameters can be set by appending named arguments to the call. Examples:
# Sends <turbo-stream action="replace" target="clearance_5"><template><div id="clearance_5">My Clearance</div></template></turbo-stream>
# to the stream named "identity:2:clearances"
clearance.broadcast_replace_to examiner.identity, :clearances
# Sends <turbo-stream action="replace" target="clearance_5"><template><div id="clearance_5">Other partial</div></template></turbo-stream>
# to the stream named "identity:2:clearances"
clearance.broadcast_replace_to examiner.identity, :clearances, partial: "clearances/other_partial", locals: { a: 1 }
92 93 94 |
# File 'app/models/concerns/turbo/broadcastable.rb', line 92 def broadcast_replace_to(*streamables, **rendering) Turbo::StreamsChannel.broadcast_replace_to *streamables, target: self, **broadcast_rendering_with_defaults(rendering) end |