A
A
Anton2016-07-29 01:53:50
Ruby on Rails
Anton, 2016-07-29 01:53:50

How to override the delete session method in Devise?

In the file sessions_controller.rb I tried to perform various manipulations with:

def destroy
  super
end

But this did not affect the actions when clicking on the link.
The route still refers to the same file that I edited:
devise/sessions#destroy

When exiting, some strange redirection occurs - after exiting, modal windows and so on do not work for me. In short - all JS Khokhloma. Such nonsense is noticeable only after the release. if it goes through the pages after the exit, then nothing works either. You have to manually reload the page. Therefore, I want to add a normal redirect to the session deletion method.
Help me please.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
Jax, 2016-07-29
@nuvanda

To override the default Devise gem methods, you need the following:

# app/controllers/sessions_controller.rb
class SessionsController < Devise::SessionsController
  def destroy
    # your code here
  end
end

In routes:
# app/config/routes.rb
devise_for :users, controllers: {sessions: 'sessions'}

But, most likely, this is not necessary to solve your problem.
You should only read about the 'turbolinks' gem (included in the rails application by default):
Article on habrahabr - better in full, at least from the section 'Problems with existing scripts' ;
The stackoverflow answer is in English.
If you don't feel like reading, the short answer is: delete the line
# /app/assets/javascripts/application.js
//= require turbolinks

thereby completely disabling turbolinks in the app.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question