简体   繁体   中英

Cannot logout of rails application devise gives error Could not find devise mapping for path "/tuners/sign_out

I have this issue when loging out of devise:

Could not find devise mapping for path "/tuners/sign_out". This may happen for two reasons: 1) You forgot to wrap your route inside the scope block. For example: devise_scope :user do get "/some/route" => "some_devise_controller" end 2) You are testing a Devise controller bypassing the router. If so, you can explicitly tell Devise which mapping to use: @request.env["devise.mapping"] = Devise.mappings[:user]

My routes file

    Rails.application.routes.draw do


  devise_for :tuners 
  get '/tuners/sign_out' => 'devise/sessions#destroy'
  resources :hardy_pianos
  devise_for :admins
  resources :images
  resources :entries
  resources :models
  get '/clients/mail_room' => 'clients#mail_room'
  get '/clients/mail' => 'clients#mail'

  #list of clients to reschedule
  get '/clients/book_again' => 'clients#book_again'  
  # current upcoming jobs 
  get '/clients/current' => 'clients#current' 
  # reports 
  get '/clients/reports' => 'clients#reports' 
  resources :clients

  seems_rateable
  post '/rate' => 'rater#create', :as => 'rate'
  resources :technicians
  resources :members
  resources :admins


  resources :tuners
  get 'tuners/tuners_pianos'
  get 'pianos/tuners_pianos'

  resources :tuners
  resources :journals
  resources :expenses
  resources :interests
  resources :purchases
  resources :contacteds
  resources :pianos
  get '/pianos/work_needed' => 'pianos#work_needed'
  get '/invoices/work_needed' => 'invoices#work_needed'
  resources :invoices
  resources :pages
  #devise_for :installs
  resources :prosperities
  get '/finances/taxes' => 'finances#taxes'
  resources :posts
  get '/tunings/current' => 'tunings#current' # or match for older Rails versio
  get '/tunings/bookagain' => 'tunings#bookagain' # or match for older Rails version
  get '/tunings/bookagain12' => 'tunings#bookagain12'
  get '/tunings/reports' => 'tunings#reports'
  get '/tunings/information' => 'tunings#information'
  resources :tunings
  root 'pages#index'
  get '/' => 'tunings#current'

# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end

Can anyone help me understand what the issue is here with this? I'm kind of stuck with this and have googled for a while but left it on the back burner. Thanks in advance.

Replace the line:

 get '/tuners/sign_out' => 'devise/sessions#destroy'

with

delete 'sign_out', to: 'devise/sessions#destroy'

or can you try this this. watch the order of lines.:

 Rails.application.routes.draw do

devise_scope :tuners do
   get "sign_out", to: "devise/sessions#destroy"
end
  devise_for :tuners 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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