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 }
# Sends <turbo-stream action="replace" method="morph" 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, :clearance, attributes: { method: :morph }, partial: "clearances/other_partial", locals: { a: 1 }
267 268 269 |
# File 'app/models/concerns/turbo/broadcastable.rb', line 267 def broadcast_replace_to(*streamables, **rendering) Turbo::StreamsChannel.broadcast_replace_to(*streamables, **(rendering, target: self)) unless suppressed_turbo_broadcasts? end |