Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

75
Visualizações
Rails API - how to send especific information with action cable for front-end

I'm trying to send for front-end an especific information (how many registers I have, with a colunm null in database), with ActionCable, but I'm using Rails Api mode.

I'm generate a channel, and don't create a authentication code (all can access), and create a method subscribed:

  def subscribed
    stream_from "password_channel"
  end

Configured CORS and WebSocket access. After I call the channel with this code in controller, to send a message for subscribed clients.

PasswordChannel.broadcast_to("password_channel", { title: "Oi" })

And create this js for consume informations in WebSockets

let webSocket = new WebSocket("ws://localhost:3000/cable")

webSocket.addEventListener("message", function(event) {
    console.log(event)
})

This js return this object:

Object

But this object don't have the information { title: "Oi" }

Here it is github repository

Can anyone help me figure out what I'm doing wrong? =)

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda