I want to make my app in real time
This is my error
ActionView::Template::Error (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 theWarden::Manager
middleware is present in your middleware stack. If you are seeing this on one of your tests, ensure that your tests are either executing the Rails middleware stack or that your tests are using theDevise::Test::ControllerHelpers
module to inject therequest.env['warden']
object for you.)
1: -if user_signed_in?
2: .ui.popup.computer{id:"post#{post.id}user#{post.user.id}", style:"padding:0px"}
3: .ui.card
4: .image
I don't know what to do
Help me please.
I think I found a solution for my case.
Define renderer_with_signed_in_user
class method in ApplicationController
.
class ApplicationController < ActionController::Base
...
def self.renderer_with_signed_in_user(user)
ActionController::Renderer::RACK_KEY_TRANSLATION['warden'] ||= 'warden'
proxy = Warden::Proxy.new({}, Warden::Manager.new({})).tap { |i|
i.set_user(user, scope: :user, store: false, run_callbacks: false)
}
renderer.new('warden' => proxy)
end
...
end
And then you can render from other parts of Rails app, like this:
renderer = ApplicationController.renderer_with_signed_in_user(user)
renderer.render template: 'notifications/show', layout: false, locals: { foo: 'bar' }
Credit to Stefan Wienert for his article
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With