-
-
Save wclittle/06829c9dd1bd087687a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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