Michael Surratt

Joined

820 Experience
8 Lessons Completed
0 Questions Solved

Activity

Sure, this can be done in my different ways. You could include a "data-user-id='#{current_user.id}'" in your template and set the selector option in your cable_ready call to be "[data-user-id='#{current_user.id}']".

This would work, but if your use case is to only update to the current user, Stimulus Reflex does that out of the box.

Great episode.

Just as a note to anybody watching this who might be wondering, cable_ready pairs perfectly well with Stimulus Reflex as well. You can simply include the cable_ready call in your *_reflex.rb file and it will cause the reflex change to be broadcast out to every connected client at the same time as the reflex (technically right before, but close enough).

Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

© 2024 GoRails, LLC. All rights reserved.