2

我正在使用 Hotwire 并在 Rails 6.0.3.6 应用程序上设计用户。

我为用户添加此广播

class User    
  after_create_commit { broadcast_append_to 'users' }
end

然后,当创建用户时,它会通过我尝试使用设计助手的部分(用户/用户)。current_user

但是 Rails 抛出这个错误:

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.

也许解决方案是能够告诉 Rails 以下内容:

如果从模型中,您尝试渲染他的默认部分(.to_partial_path),您需要向它传递一些局部变量,例如user: self.

我怎么能对 Rails 这么说呢?

谢谢你的帮助

4

1 回答 1

1

DHH 说:

用于 turbo 流的部分必须没有全局引用,因为它们是由 ApplicationRenderer 呈现的,而不是在特定请求的上下文中。

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

于 2021-04-19T15:52:13.137 回答