Forum: Ruby on Rails how to see who is online?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
F0f816437222a5266dd38fa9d87d9764?d=identicon&s=25 Feng (Guest)
on 2007-04-29 08:17
dear all,

how can i see who is "online", and show the total number of people on my
web ?


7223c62b7310e164eb79c740188abbda?d=identicon&s=25 Xavier Noria (Guest)
on 2007-04-29 10:32
(Received via mailing list)
On Apr 29, 2007, at 8:17 AM, Feng wrote:

> how can i see who is "online", and show the total number of people
> on my
> web ?

Being online is an ill-defined concept.

An approximation that might be good enough is to maintain a field in
the users table called last_seen_at. Update it at each request in a
high-priority filter. Then define to be online using a time window,
say 3 minutes:

   class User
     def online? - last_seen_at < 3.minutes

-- fxn
Ff168162d53e22788d576582b3527e97?d=identicon&s=25 Bill Kocik (Guest)
on 2007-04-29 15:11
(Received via mailing list)
You could also include an Ajax function in each page that hits a "I'm
still here" URL on a timer, so you can tell if they've still got your
page open even if they're not requesting new pages. But, that
demonstrates that Xavier's assertion that "online is an ill-defined
concept" is definitely true. Are they online if they opened your page
12 hours ago and haven't been near their computer since? So maybe the
function only runs up to N times and then stops unless the page
refreshes or changes . . .

But in the real world, if you want to know how many (most?) popular
sites actually accomplish this - MySpace for example - they just use
Userplane to do it for them. They've already figured it all out.
F0f816437222a5266dd38fa9d87d9764?d=identicon&s=25 Feng (Guest)
on 2007-04-29 17:26
Thank you all :)

Now I know what to do. thanks again :)

This topic is locked and can not be replied to.