I am having a complete brain meltdown in regards to turbo rails. Scenario:
I have a post model that can have comments, a user should be able to edit their own comments. I have a turbo stream-based of the post id so that any comments added to a post are pushed using action cable to each viewer of the post,
Now, I’d like to skip posting the comment to the user adding the post because they already receive the update using the controller.
The problem is that for the author, the added comment should have edit and delete functionality but for the others not (I use cancancan for authentication).
The problem I am facing is that either all users subscribed to the post get to edit/destroy authentication (providing the current user as an actor) or none gets it because the author first gets the partial from the controller (everything works) and then it gets overwritten by the broadcast later job.
What am I missing here? There has to be an acceptable and super easy solution that I am not thinking of.