我試圖在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是的,那是票中引用的鏈接之一。 –