Skip to content

Devise extension for logging current active users logged in using only the fast Rails cache and not your database

License

Notifications You must be signed in to change notification settings

westonganger/devise_whos_here

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Devise Who's Here

Buy Me a Coffee

Devise extension for logging current active users using only the fast Rails cache. This gem is for if you don't want long-term storage of this information and don't want to write to your database all the time.

Install

# Gemfile

gem 'devise_whos_here'

Usage

# app/models/user.rb

devise :database_authenticatable, :confirmable, :whos_here

This will keep track of your logged in users with a variable in the Rails cache. Note all below times are returned as Time objects, not strings.

User.last_active_since(30.minutes.ago) # returns an array of User objects

user = User.first

user.last_here_at # returns last known request time

Whenever you want to clear the cache simply run

User.clear_whos_here!

Credits

Created by Weston Ganger - @westonganger

Buy Me a Coffee

About

Devise extension for logging current active users logged in using only the fast Rails cache and not your database

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages