Skip to content

Instantly share code, notes, and snippets.

@lchanmann
Created May 29, 2018 14:52
Show Gist options
  • Save lchanmann/c26fa3c036c9f6f8f2aad7180500c850 to your computer and use it in GitHub Desktop.
Save lchanmann/c26fa3c036c9f6f8f2aad7180500c850 to your computer and use it in GitHub Desktop.
class ChatChannel < ApplicationCable::Channel
def subscribed
stream_from "my_channel"
end
def send_message(data)
message_params = { sent_by: current_user }.merge(data['message'])
ActionCable.server.broadcast("my_channel", message_params)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment