Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/westonganger/devise_whos_here
Devise extension for logging current active users logged in using only the fast Rails cache and not your database
https://github.com/westonganger/devise_whos_here
active-users devise rails ruby users
Last synced: about 2 hours ago
JSON representation
Devise extension for logging current active users logged in using only the fast Rails cache and not your database
- Host: GitHub
- URL: https://github.com/westonganger/devise_whos_here
- Owner: westonganger
- License: mit
- Created: 2017-07-12T18:01:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-06-05T18:32:54.000Z (over 6 years ago)
- Last Synced: 2024-12-19T15:51:49.371Z (15 days ago)
- Topics: active-users, devise, rails, ruby, users
- Language: Ruby
- Size: 4.88 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
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```ruby
# Gemfilegem 'devise_whos_here'
```# Usage
```ruby
# app/models/user.rbdevise :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.
```ruby
User.last_active_since(30.minutes.ago) # returns an array of User objectsuser = User.first
user.last_here_at # returns last known request time
```Whenever you want to clear the cache simply run
```ruby
User.clear_whos_here!
```# Credits
Created by Weston Ganger - @westonganger