ruby-on-railse-commercespreespree-auth-devise

Admin logout redirect in Spree e-commerce


I am working on a spree e-commerce developed in ruby-on-rails and when you logout from the admin panel you are taken to the store home. I need to stay in admin section (log in page) after log out from admin. The problem is that I have installed 'spree_auto_devise' gem and I don't know how to overwrite the route after the user destroy method.

Can anybody help me please?


Solution

  • To change the default logout behavior to stay on the same page, just add this code to .../your-spree-website/app/controllers/application_controller.rb

    def after_sign_out_path_for(resource_or_scope)
      URI.parse(request.referer).path if request.referer
    end
    

    I found the solution here: https://github.com/plataformatec/devise/wiki/How-To:-redirect-to-a-specific-page-on-successful-sign_in,-sign_out,-and-or-sign_up