Skip to content

Instantly share code, notes, and snippets.

@wclittle
Created December 28, 2015 23:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wclittle/06829c9dd1bd087687a1 to your computer and use it in GitHub Desktop.
Save wclittle/06829c9dd1bd087687a1 to your computer and use it in GitHub Desktop.
class MessageBroadcastJob < ApplicationJob
queue_as :default
def perform(message)
ActionCable.server.broadcast 'room_channel', message: ActiveSupport::JSON.decode(render_message(message))
end
private
def render_message(message)
ApplicationController.renderer.render(partial: "messages/message.json.jbuilder", locals: {message: message})
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment