Skip to content

Instantly share code, notes, and snippets.

@scottdomes
Created July 26, 2017 23:07
Show Gist options
  • Save scottdomes/8987595f8a9feaa6767f87462203d3b3 to your computer and use it in GitHub Desktop.
Save scottdomes/8987595f8a9feaa6767f87462203d3b3 to your computer and use it in GitHub Desktop.
Note channel
class NotesChannel < ApplicationCable::Channel
def subscribed
# stream_from "some_channel"
stream_from 'notes'
end
def unsubscribed
# Any cleanup needed when channel is unsubscribed
end
def receive(data)
note = Note.find(data["id"])
note.update!(text: data["text"])
ActionCable.server.broadcast('notes', data)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment