繁体   English   中英

Devise注销/注销不适用于Rails 4

[英]Devise Sign Out/Log Out not working with Rails 4

我讨厌发布有关此的另一个主题,因为似乎有十几个主题,但是我找不到能为我解决这个问题的主题。

在我的application.html.erb我有:

<% if user_signed_in? %>
    Logged in as <strong><%= current_user.email %></strong>.
    <%= link_to 'Settings', edit_user_registration_path %> |
    <%= link_to "Log out", destroy_user_session_path, method: :delete %>
  <% else %>
    <%= link_to "Sign up", new_user_registration_path %> |
    <%= link_to "Log in", new_user_session_path %>
  <% end %>

routes如下所示:

devise_for :users, 
    path_names: {sign_in: "login", sign_out: "logout"}
  resources :users
  resources :addresses

  root 'users#index'
  get 'dashboard', to: "users#dashboard"

我的本地日志如下所示:

started GET "/users/logout" for 127.0.0.1 at 2013-10-21 17:47:21 -0700
Processing by UsersController#show as HTML
  Parameters: {"id"=>"logout"}
  User Load (0.2ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
  Rendered users/show.erb within layouts/application (1.2ms)

因此,与许多其他主题一样,它正在尝试将logout作为id传递。 我的application.html.erb链接中包含:delete ,不是这样。

这是我的application.js

//= require jquery
//= require jquery_ujs
//= require_tree .

看起来很好。

有任何想法吗? 我难过...

编辑: rake routes输出

                  Prefix Verb   URI Pattern                    Controller#Action
        new_user_session GET    /users/login(.:format)         devise/sessions#new
            user_session POST   /users/login(.:format)         devise/sessions#create
    destroy_user_session DELETE /users/logout(.: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
                         PATCH  /users/password(.:format)      devise/passwords#update
                         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
                         PATCH  /users(.:format)               devise/registrations#update
                         PUT    /users(.:format)               devise/registrations#update
                         DELETE /users(.:format)               devise/registrations#destroy
                   users GET    /users(.:format)               users#index
                         POST   /users(.:format)               users#create
                new_user GET    /users/new(.:format)           users#new
               edit_user GET    /users/:id/edit(.:format)      users#edit
                    user GET    /users/:id(.:format)           users#show
                         PATCH  /users/:id(.:format)           users#update
                         PUT    /users/:id(.:format)           users#update
                         DELETE /users/:id(.:format)           users#destroy
               addresses GET    /addresses(.:format)           addresses#index
                         POST   /addresses(.:format)           addresses#create
             new_address GET    /addresses/new(.:format)       addresses#new
            edit_address GET    /addresses/:id/edit(.:format)  addresses#edit
                 address GET    /addresses/:id(.:format)       addresses#show
                         PATCH  /addresses/:id(.:format)       addresses#update
                         PUT    /addresses/:id(.:format)       addresses#update
                         DELETE /addresses/:id(.:format)       addresses#destroy
                    root GET    /                              users#index
               dashboard GET    /dashboard(.:format)           users#dashboard
       send_im_home_text GET    /im_home(.:format)             users#im_home

缺少<%= javascript_include_tag :application %>application.html.erb如在注释中提到。

暂无
暂无

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

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