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 4004466
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:16:37+00:00 2026-05-20T08:16:37+00:00

I have a Rails 3 application and it’s using Devise for the authentication. I

  • 0

I have a Rails 3 application and it’s using Devise for the authentication.

I would like to display the date and time each user last logged in within the administration table of users.

I have based the application on the following application:

https://github.com/dannymcc/rails3-base

I have read through the Devise GitHub wiki and notice that it mentions that user events are trackable, but I can’t find any information regarding accessing the information etc.

Any help/advice would be greatly appreciated!

Thanks,

Danny

  • 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-20T08:16:37+00:00Added an answer on May 20, 2026 at 8:16 am

    The Devise documentation outlines the trackable module which will do what you want. In your user model, include the :trackable module like so:

      devise :database_authenticatable, 
          ...
          :trackable
    

    And make sure your database has the right fields. Not sure how do this if you already have a user table, but adding fields with the right names and types should do the trick. My migration to create my users table looks like so:

    class CreateUsers < ActiveRecord::Migration
      def self.up
        create_table :users do |t|
          t.string :name
          t.string :email
    
          t.database_authenticatable :null => false
          t.recoverable
          t.rememberable
          t.trackable
    
          t.timestamps
        end
      end
    
      def self.down
        drop_table :users
      end
    end
    

    The t.trackable will add the correct fields. In my user model, they’re as follows:

    sign_in_count: integer, 
    current_sign_in_at: timestamp, 
    last_sign_in_at: timestamp, 
    current_sign_in_ip: string, 
    last_sign_in_ip: string
    

    Then you can just do user.last_sign_in_at and check the strftime documentation on how to output the time in the format you want.

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

Sidebar

Related Questions

I have a rails application where each user has a separate database. (taking Joel
I have a rails application running on a Linux server. I would like to
I have a Rails application for which I use devise to authenticate my users
I have a rails application which is still showing the cachebusting numeric string at
I have a Rails application that in the erb code, I use a select
We have a rails application in subversion that we deploy with Capistrano but have
I have a Rails application that unfortunately after a request to a controller, has
I've got a rails application where users have to log in. Therefore in order
I am working on a rails application (I have some experience with rails). But,
I'm looking at building a Rails application which will have some pretty large tables

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.