设计:未知操作,无法找到路径“/ accounts / sign_out”的设计映射

时间:2011-05-02 09:58:24

标签: ruby-on-rails devise

每次我将浏览器指向“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"}

1 个答案:

答案 0 :(得分:1)

问题是在routes.rb中我还在resources :accounts之前声明了devise_for路由。因此,解决方案最终是在devise_for声明之后:

devise_for :accounts, :controllers => { :registrations => :accounts  }
resources :accounts