stream_for is just a stream_from wrapper stream_from with ease.
When you need a stream related to a specific model, stream_for automatically generates a broadcast from the model and channel for you.
Suppose you have a chat_room instance of the chat_room class,
stream_from "chat_rooms:#{chat_room.to_gid_param}"
or
stream_for chat_room # equivalent with stream_from "chat_rooms:Z2lkOi8vVGVzdEFwcC9Qb3N0LzE"
two lines of code do the same.
https://github.com/rails/rails/blob/master/actioncable/lib/action_cable/channel/streams.rb
source share