Signed-stream-name is the same even though the association is different in broadcasting of Turbo Streams @ Rails 7

Viewed 36

I'm making it according to This tutorial, but it does not work properly even if the same code (in my perception) as the tutorial. So, I'm in trouble because I don't know what caused it. Details are given below, so please let me know if you have any doubts.

Deveropment environment
Rails 7.0.3

The problematic part is the broardcasting function of trurbo-stream, and the following changes will make the signed-steam-name different for each association (company).

app/models/quote.rb

# before
  broadcasts_to ->(quote) { 'quotes' }, inserts_by: :prepend
# after
  broadcasts_to ->(quote) { [quote.company, 'quotes'] }, inserts_by: :prepend

Until I rewrote this code, singed-stream-name was the same regardless of the company I belonged to. Real-time update by broadcast was enabled. After rewriting, singed-stream-name was the same regardless of the company I belonged to. Real-time update by broadcast was disabled.(even if same company user) In other words, the rewritten code is useless?? I restarted the server and checked it, but there was no change.

0 Answers
Related