2

This error has been driving me and a fellow dev insane. We're building an app with Ruby/Rails jazz, and whenever I click to logout for a user session, I get this error:

Routing Error

No route matches [GET] "/users/sign_out"
Try running rake routes for more information on available routes.

Now I've ran rake routes a ton, and I get:

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
                    root        /                              home#index
                   about        /about(.:format)               home#about

Is there anything to be done here? I've also followed the answers of a lot of the posts here on Stack Overflow to no avail. Anything else I can test to try to fix this problem?

EDIT: Here is logout link code

<a href="/users/sign_out" class="header-links right-link" data-method="delete" rel="nofollow">Logout</a
4

4 回答 4

1

检查您的 HTML 并确保 rails.js 已加载,并且没有 javascript 错误。如果您使用的是 jQuery,请确保没有冲突

注意:我的猜测是您正在运行 rails 版本 < 3.1,因此请检查您的布局中是否存在这两行

<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
于 2013-04-29T06:03:47.963 回答
1

尝试:

<%= link_to "Logout", destroy_user_session_path, method: :delete %>
于 2013-04-29T07:19:30.650 回答
1

你的路线在“devise_for”下有这个吗?:

get 'users/sign_out' => 'sessions#destroy', :as => :destroy_user_session

并尝试将此作为链接:

<%= link_to "Logout", destroy_user_session_path, method => :delete %>
于 2013-04-29T07:41:44.943 回答
0

检查您的 routes.rb 是否有,

devise_for :users, ActiveAdmin::Devise.config

有时我的安装似乎错过了这部分ActiveAdmin::Devise.config,然后我得到了这个错误。

我在gem 的生成器中看到它,但有时它不会添加到我的应用程序中。

于 2014-03-01T07:53:22.393 回答