Ask A Question

Notifications

You’re not receiving notifications from this thread.

Could we get a video on passing Devise current_user (or general user roles) into a Turbo partial?

Marc Jaramillo asked in General

Hi Chris,

I was just wondering if there is any possibility of getting a video or some tips on including Devise current_user data or user roles inside a turbo stream - specifically to show/hide edit and delete links? I've gotten a threaded comment feature working after going through the Real-Time Nested Comments videos, but I can't get the edit/delete links working. In this post, DHH says "Partials used for turbo streaming have to be free of global references, as they’re rendered by the ApplicationRenderer, not within the context of a specific request" and in this closed issue he says "You'll need to make a partial that's not dependent on global state like this to work. You can use client-side show/hide using a stimulus controller instead". I've tried to find ideas on work arounds, and I've seen a few workarounds: this one with CSS and this one using local variables. I've tried adapting both of these approaches to my project, but no dice.

Reply

+1
This is something I came up following the "Realtime Apps with Hotwire & ActionMailbox" video series

Reply
Join the discussion
Create an account Log in

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

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

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