Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

onlineable

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

onlineable

  • 1.0.1
  • Rubygems
  • Socket score

Version published
Maintainers
2
Created
Source

onlineable

Gem for Rails application - provides you list of online users (for authentication gem 'devise') for ActiveRecord ou Mongoid.

Installation

Add this line to your application's Gemfile:

gem 'onlineable'

And then execute:

$ bundle install

Next you have to run this to make it install the initializer

$ rails g onlineable:install

*Note: if you are doing this on a Heroku server run the following command:

$ heroku run rails g onlineable:install

Do not do a run:detached as it prompts you and you will have to manually terminate the process if you run:detached.

Usage

For using functionality add to ApplicationControler:

  before_action { |c| current_usuario.track_online unless current_usuario.nil?}

This will make the app consider the online user while they interact with the application.

and In your template, add: onlineable-by-todd for the current device line at the end, and if you want to change the time (in seconds or minutes) that a user is considered online add below: time seconds: n or time minutes: n, the default is seconds: 30.

class User < ActiveRecord::Base
	devise ..., :onlineable
	time seconds:30 #or
	time minutes:2
end

Helper for online users list (for the whole list, not just an individual):

Model.who_online, e.g. User.who_online, Admin.who_online

To see if a user is online you would run something like this:

User.who_online.include?(user)

Now you can override the default time to check for user activity. It defaults to 15 seconds (i.e. if the user hasn't done anything for 15 seconds they are not considered online). To override this with say 30 seconds you would do the following:

User.who_online(30).include?(user)

I have also modified the code to work more easily with RedisToGo on Heroku. It now works with RedisToGo on Heroku, it needed the password to be parsed, now it is.

Requirement

  • Redis; this gem will make sure the dependencies get installed but you have to make sure you have it on your server, for Heroku I recommend RedisToGo.

  • Devise;

FAQs

Package last updated on 17 Sep 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc