Ask A Question

Notifications

You’re not receiving notifications from this thread.

How Do I send a "Turbo Hotwire Broadcast" only when a record with a specific name value is created or updated, and for a specific partial?

Luis Cuevas asked in Rails

Hello, you have a great community in Gorails. I have a Rails View with 3 numerical integer indicators: speed, temperature and pressure.
These values ​​are stored in SavedObject model as serialized objects. And in the controller are passed to the view with their respective instance variables. @speed @temperature @pressure

The question

How can I send a separate broadcast (with turbo hotwire) for each serialized object conditioned by the "name" column (like "Device 2 Temperature") , when this is updated, so each broadcast reach to their own partial? (there are three different partials in the same view)

This is the model

class SavedObject < ApplicationRecord
serialize :value
end

These are the columns.

t.string :name
t.text :value

Record Example

id: 144,
name: "Device 2 Temperature",
value: [{last_value: "52", equip_id: 2}]```
Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,400+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.