devise: Warden Key Missing - Action Cable
I’ve got an up to date Rails 5 app running Devise, and Action Cable. I can authorize the connection just fine, that is not the problem. The issue is using current_user helper within a notification partial that’s pushed out using Action Cable. It’s causing an error because no middleware is exec in Action Cable.
TLDR;
- model record contains an after action that creates a notification record
- notifications are background jobs, thus they do NOT stem from a controller
current_userhelper causing error of missing warden key when used in a partial broadcasted with action cable
This sums it up better than I can. Here’s the accompanying link: https://evilmartians.com/chronicles/new-feature-in-rails-5-render-views-outside-of-actions

I’ve tried a few work arounds and haven’t had much luck, and I’m definitely not in the mindset of monkey patching. Any thoughts?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 16 (5 by maintainers)
I’m bumping this again after researching on Google how to fix this error, and coming across my own bug report from back in March. I realize you don’t get paid to maintain this gem but if you have any thoughts, I’d love to hear them.
I was facing the same problem, when I tried to use
ApplicationController.renderto render the partial view that I want to pass to the action cable.I’ve got the solution from the article linked below, but this solution makes
sign_in_countincrease whenever rendering a partial view usingApplicationController.render_with_signed_in_user.https://www.stefanwienert.de/blog/2016/04/05/using-rails-5-new-renderer-with-authentication-gems-like-clearance-or-devise/
Hi there,
I’m running a project that uses:
We are using Action Cable, and for authentication using Devise and Warden, we have the following code in the
app/channels/connection.rbfile.Hope it helps. Regards.
Actually, this is an issue that happens when you want to render a partial outside of your actions…Like in a job, and your partial uses devise helpers (current_user, user_signed_in? etc). This is similar to the following issue: https://github.com/plataformatec/devise/issues/4271