How to define the way instance model should be rendered in Rails 6

502 Views Asked by At

I'm using Hotwire and devise User on a Rails 6.0.3.6 app.

I add this broadcast for Users

class User    
  after_create_commit { broadcast_append_to 'users' }
end

Then when a User is created it goes through his partial (users/user) where I am trying to use current_user Devise helper.

But Rails throw this error:

Devise::MissingWarden in Players::Registrations#update
Devise could not find the `Warden::Proxy` instance on your request environment.
Make sure that your application is loading Devise and Warden as expected and that the `Warden::Manager` middleware is present in your middleware stack.

Maybe the solution would be to be able to tell Rails the following:

If from a model, you are trying to render his default partial (.to_partial_path) you need to pass it some locals variables,like user: self.

How could I say that to Rails ?

Thanks for you help

1

There are 1 best solutions below

0
On

DHH said:

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.

https://discuss.hotwire.dev/t/authentication-and-devise-with-broadcasts/1752/4