Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6126469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:22:42+00:00 2026-05-23T16:22:42+00:00

For Devise user models that use :token_authenticatable , like so class Voter < ActiveRecord::Base

  • 0

For Devise user models that use :token_authenticatable, like so

class Voter < ActiveRecord::Base
  devise :token_authenticatable
end

there used to be a route called destroy_user_session, so that you could log users out by linking to destroy_user_session_path. This seems to have changed in recent versions — now only :database_authenticatable creates a destroy route for me.

So for users that use token authentication, what is the proper way to implement a “log out”/”sign out” action to end their sessions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:22:42+00:00Added an answer on May 23, 2026 at 4:22 pm

    By default, when you sign in via token, Devise will store the user in session just like in the database authentication strategy.

    You can disable this by setting stateless_token to true in the Devise initializer:

    Devise.setup do |config|
      config.stateless_token = true
    end
    

    This way, the token must be provided with every request.


    As I understand it, token authentication was designed to be used together with database authentication. devise_for will only add the session routes if your model is database_authenticatable. This seems like a minor oversight on Devise’s part, but in my opinion, access tokens leaving the user in session doesn’t make much sense to me to begin with.

    Anyway, try to define the routes to Devise’s sessions manually.

    Adapted from Devise’s routing helpers (untested code):

    as :user do  # User scope
      resource :session, :controller => 'devise/sessions' do
        # new_user_session | GET /users/sign_in => devise/sessions#new
        get :new, :path => 'sign_in', :as => "new"
    
        # user_session | POST /users/sign_in => devise/sessions#create
        post :create, :path => 'sign_in'
    
        # destroy_user_session | GET /users/sign_out => devise/sessions#destroy
        get :destroy, :path => 'sign_out', :as => "destroy"
      end
    end
    

    In any case, the documentation for the devise_for helper specifies which routes are created and what they point to.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Devise for my User model and sessions control. I'd like to use
I use devise for authentication. In my User model there is a field locale,
Rails 3 newbie here... I'm working to create a devise auth system that like
Is it possible to configure Devise to accept logins for multiple models (either User
I currently have a simple app that includes user authentication through devise and a
I'm writing a python module for a device that interacts with a user supplied
Rails 3 newbie here.... I'm looking to build an application that limits a user's
rails 3 newbie, using Devise for auth... I want to create the following models:
I am using devise but the User model is related to a legacy table
What's the rails way to see posts nested beneath several associative models that a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.