我试图在ActionJob中通过ActionCable播放模板。ActionCable + Devise + Pundit + ApplicationController.render
ApplicationController.render(partial: "messages/message", locals: { message: message }, assigns: { current_user: user}).squish
在大多数情况下,这工作得很好,但是我的一些模板在视图中使用Punit进行授权。
<% if policy(message).show? %>
<%= message.body %>
<% end %>
这会在作业运行时产生错误。
ActionView::Template::Error: Devise could not find the `Warden::Proxy` instance on your request environment.
快速谷歌搜索发现此问题:https://github.com/plataformatec/devise/issues/4271
中票和链接中提到,没有ENV [“看守”]用,因为没有中间件已经执行添加它。
我该如何解决这个问题?
您是否检查过[this](http://www.thegreatcodeadventure.com/using-action-controller-renderers-in-rails-5-with-devise/)? –
@ArunKumar是的,那是票中引用的链接之一。 –