简体   繁体   English

要将路线添加到Ruby on Rails Spree Commerce应用程序?

[英]Adding route to Ruby on Rails Spree Commerce app?

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. Spree Commerce中带有spree_auth_devise的一个已知问题 (?)是,当您在管理页面上单击注销链接时,该链接不起作用。 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. 我知道路由[root] /登出有效并且提供了适当的登出。 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). 现在,我试图将上述无效的链接重定向到[root] /登出链接(当您从管理页面执行/ logout获取请求时,它可以正常工作)。 The /logout routes to spree/user_sessions#destroy . / logout路由到spree/user_sessions#destroy

In routes.rb I tried adding the following: routes.rb我尝试添加以下内容:

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? 如何正确将路径user / spree_user / logout路由到工作注销操作?

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. “存储”是您的Spree根目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM