Hotwire Discussion

Broadcast later with current_user

Hi,

I have been looking for a best practice to handle this kind of things, did not found…

I have a list of tasks that are visible to everyone, but “doable” only by some users. To differentiate visually the tasks, the not doable one are striped.
When a task is changed, I need to broadcast the change to everyone. I removed every occurrence of current_user in the task partial so the broadcast work. But I still need to add the stripe on the undoable task.
I was going to add the ids of the user that can do the task in a data attribute, and then check by javascript if the current user id (given in a meta tag) is included in this list. If not, add the stripe.

Is it a good solution ? Is there anything better to do ?

Thank you for any tips :slight_smile:

PS: Pardon my english, I am french.
PS: Hotwire is incredible

Bonjour @Teddy_Valente,

C’est rare, ici, ainsi parlons français :slight_smile:

I was going to add the ids of the user that can do the task in a data attribute, and then check by javascript if the current user id (given in a meta tag) is included in this list. If not, add the stripe.

Oui, c’est comme cela que j’opère. Ayant parcouru différents articles il y a quelques mois de cela, c’est la manière de faire.

Cordialement,

Cool, un frenchy :wink:

C’est bien ce que je pensais. Merci pour la confirmation.

1 Like