每次我将浏览器指向“account / sign_out”(GET请求)时,我都会收到此错误:
Unknown action, Could not find devise mapping for path "/accounts/sign_out"
这是我的设计路线:
devise_for :accounts, :controllers => { :registrations => :accounts }
它必须是微不足道的,但我不明白。文档说,设计已经提供了一个退出操作,并将其绑定到这个确切的路由“/ accounts / sign_out”。请与我分享我做错了什么?
rake routes
的输出显示操作已映射:
destroy_account_session GET /accounts/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
答案 0 :(得分:1)
问题是在routes.rb中我还在resources :accounts
之前声明了devise_for
路由。因此,解决方案最终是在devise_for
声明之后:
devise_for :accounts, :controllers => { :registrations => :accounts }
resources :accounts