设计不从ERB链接签出

时间:2016-11-20 07:12:07

标签: ruby-on-rails devise

我有一个带有Devise登录系统的应用程序,用于域和所有子域。它以前工作正常,但现在退出功能由于某种原因不起作用。

我试过这个作为我的退出链接:

<%= link_to "Sign Out", destroy_user_session_path, :method => :delete %>

或者,根据建议的here,这是我的退出链接:

<%= link_to "Sign out", logout_path, :method => :delete %>

在我的路线中有这个:

devise_scope :user do
  delete "logout" => "devise/sessions#destroy", :as => "logout"
end

无论哪种方式,我点击链接并在我的服务器中得到类似的内容:

Started DELETE "/logout" for 127.0.0.1 at 2016-11-19 23:09:51 -0800
Processing by Devise::SessionsController#destroy as HTML
  Parameters: {"authenticity_token"=>"tbFG+joMI84Z/fu9YxCTDj+2Ltp8Wm0tC8ClirXIL4Z8+e7xuePzbn0cPyY0Ljj/UA1rxO+q3WFuO3BNHMJXTQ=="}
  User Load (0.1ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ?  ORDER BY "users"."id" ASC LIMIT 1  [["id", 1]]
   (0.1ms)  begin transaction
   (0.1ms)  commit transaction
Redirected to http://lvh.me:3000/
Completed 302 Found in 3ms (ActiveRecord: 0.2ms)


Started GET "/" for 127.0.0.1 at 2016-11-19 23:09:51 -0800
Processing by HomeController#index as HTML
  Rendered home/index.html.erb within layouts/application (66.5ms)
  User Load (0.1ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = ?  ORDER BY "users"."id" ASC LIMIT 1  [["id", 1]]
Completed 200 OK in 107ms (Views: 106.6ms | ActiveRecord: 0.1ms)

然而会议仍然存在。这是我的整个路由文件,如果它有帮助:

Rails.application.routes.draw do

  devise_for :users, controllers: { registrations: 'registrations' }
  resources :users, only: [:show]
  devise_scope :user do
      delete "logout" => "devise/sessions#destroy", :as => "logout"
    end

    constraints subdomain: 'liz' do
        scope module: 'liz', as: 'liz' do
            get 'home/index'
            root 'home#index'
            resources :inquiries
            resources :blogs
            get 'tags/:tag', to: 'blogs#index', as: :tag
            get 'services/hire'
            get 'services/dev'
            get 'services/design'
            get 'services/branding'
            get 'services/portfolio'
        end
    end

    constraints subdomain: 'anthony' do
        scope module: 'anthony', as: 'anthony' do
            get 'home/index'
            root 'home#index'
        end
    end

    get 'home/index'
    root 'home#index'
    resources :logs
end

以下是我的用户相关路线:

                  Prefix Verb   URI Pattern                    Controller#Action
        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
                         PATCH  /users/password(.:format)      devise/passwords#update
                         PUT    /users/password(.:format)      devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)        registrations#cancel
       user_registration POST   /users(.:format)               registrations#create
   new_user_registration GET    /users/sign_up(.:format)       registrations#new
  edit_user_registration GET    /users/edit(.:format)          registrations#edit
                         PATCH  /users(.:format)               registrations#update
                         PUT    /users(.:format)               registrations#update
                         DELETE /users(.:format)               registrations#destroy
                    user GET    /users/:id(.:format)           users#show
                  logout DELETE /logout(.:format)              devise/sessions#destroy

我不知道问题可能在哪里,但如果有人知道为什么会发生这种情况,我很乐意提供更多信息。

0 个答案:

没有答案