Destroy the administrator session, as a result of which HTTP get request 4 requests will be resolved

My Rails 4 has user and administrative models.

I implemented a project for the Admin model created using rails_admin gem. The problem occurs when I try to log out: the application redirects to an unexpected page, and the logs show that the GET requests are saved, not DELETE.

Following the research, I made sure that the logout link has the removal method listed below

<% = link_to "Admin exit", destroy_admin_session_path ,: method =>: delete%>

in devise.rb is issued using delete config.sign_out_via =: delete

Routes follow

Mvc::Application.routes.draw do resources :users devise_for :admins mount RailsAdmin::Engine => '/admin', as: 'rails_admin' root "users#index" end 

I log in perfectly without problems, but when the exit request is issued in the browser in / admins / sign _out, the session is still active and the admin control panel is still displayed on the page. Interestingly, the flash message shows that "Model" S "was not found," and I am really puzzled by what the magazines show.

 Started GET "/admins/sign_out" for 127.0.0.1 at 2014-12-03 23:10:50 +0000 Processing by RailsAdmin::MainController#show as HTML Parameters: {"model_name"=>"s", "id"=>"sign_out"} [RailsAdmin] Could not load model S, assuming model is non existing. (uninitialized constant S) Gemfile source 'https://rubygems.org' gem 'rails', '4.0.3' gem 'sqlite3' gem 'bootstrap-sass', '~> 3.3.1' gem 'uglifier', '>= 1.3.0' gem 'jquery-rails' gem 'turbolinks' gem 'jbuilder', '~> 1.2' gem 'simple_form' gem 'bcrypt-ruby' gem 'devise' gem 'rails_admin' group :assets do gem 'sass-rails', '~> 4.0.0' gem 'coffee-rails', '~> 4.0.0' gem 'uglifier', '>= 1.3.0' end group :doc do gem 'sdoc', require: false end group :development do gem 'better_errors', '~> 2.0.0' end 

What I would like to achieve is that upon logging out, the administrator session is destroyed and the administrator is redirected to root_path. I note that currently I have only the application and user controller and there is no session controller. From what I understand, the development mechanism should take out session management out of the box. Any suggestions please?

+5
source share
1 answer

It seems that you are not using the application layout file. So try adding the following code snippet to your html file

 <head> <title>Training</title> <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> </head> 
-1
source

Source: https://habr.com/ru/post/1208308/


All Articles