I'm receiving the following error while I sign out my application. This error is only found after I add an import concept in my application.
My routes.rb file:
Rails.application.routes.draw do
devise_for :users
resources :userdetails do
collection {post :import}
end
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: "userdetails#index"
devise_scope :users do
get 'sign_in', to: 'devise/sessions#new'
get 'sign_out', to: 'devise/sessions#destroy'
end
end
Controller file:
class UserdetailsController < ApplicationController
# before_action :set_userdetail, only: [:show, :edit, :update, :destroy]
before_action :authenticate_user!
# GET /userdetails
# GET /userdetails.json
def import
Userdetail.import(params[:file])
redirect_to root_url, notice: "Data imported"
end
Routes:
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
Here's my Error:
Unknown action Could not find devise mapping for path "/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]