注销与Devise无法正常工作

时间:2013-05-26 14:13:16

标签: ruby-on-rails ruby-on-rails-3 devise

我在使用devise注销时遇到问题,当我尝试注销时,我收到以下错误消息,它正在寻找具有id = sign_out的用户。有什么建议吗?

ActiveRecord::RecordNotFound in UsersController#show

Couldn't find User with id=sign_out

路线

  devise_for :users

  match 'users/settings',  to: 'users#settings'

  resources :users, only: [:show, :update]

链接

<%= link_to 'Logout', destroy_user_session_path, :method => :delete %>

Rake Routes

new_user_session GET    /users/sign_in(.:format)                          devise/sessions#new
            user_session POST   /users/sign_in(.:format)                          devise/sessions#create
    destroy_user_session DELETE /users/sign_out(.:format)                         devise/sessions#destroy
           user_password POST   /users/password(.:format)                         devise/passwords#create
       new_user_password GET    /users/password/new(.:format)                     devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format)                    devise/passwords#edit
                         PUT    /users/password(.:format)                         devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)                           devise/registrations#cancel
       user_registration POST   /users(.:format)                                  devise/registrations#create
   new_user_registration GET    /users/sign_up(.:format)                          devise/registrations#new
  edit_user_registration GET    /users/edit(.:format)                             devise/registrations#edit
                         PUT    /users(.:format)                                  devise/registrations#update
                         DELETE /users(.:format)                                  devise/registrations#destroy
          users_settings        /users/settings(.:format)                         users#settings
                    user GET    /users/:id(.:format)                              users#show
                         PUT    /users/:id(.:format)

2 个答案:

答案 0 :(得分:1)

最近我解决了这个问题,您需要尝试在view / layouts / application.html.erb中放置或检查以下行

<%= javascript_include_tag "application" %>

还要检查你的Gemfile中是否有jquery_ujs。

答案 1 :(得分:0)

确保您实际点击了正确的链接。我非常怀疑链接将请求路由到UsersController#showdestroy_user_session_path路由到/users/sign_out所以这是不可能的。