Question

I have the following relevant gems installed:

gem 'spree', github: 'spree/spree', branch: '2-1-stable'
gem 'spree_auth_devise', :git => 'https://github.com/spree/spree_auth_devise.git', 
:branch => '2-1-stable'

A known problem (?) in Spree Commerce with spree_auth_devise is that when you click the logout link while on the admin page it does not work. You get the following error:

ActionController::RoutingError (No route matches [GET] "/store/user/spree_user
         /logout"):

I am trying to solve this error. I know that the route [root]/logout works and provides a proper logout. Now I am trying to redirect the above link that does not work to the [root]/logout one (when you do the /logout get request from the admin page it works fine). The /logout routes to spree/user_sessions#destroy.

In routes.rb I tried adding the following:

Spree::Core::Engine.routes.prepend do
    get 'user/spree_user/logout', :to => 'spree/user_sessions#destroy'
end

but that still gives the same error.

How do I properly route the path user/spree_user/logout to the working logout action?

Was it helpful?

Solution

I had this same problem on a project where it wasn't cost effective to dig around. I fixed it by adding a redirect:

match "/store/user/spree_user/logout", :to => redirect('/store/logout')

Where 'store' is your Spree root.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top