Forum: Ruby on Rails Extension to book login code: list of online users?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Be732ee41fd3038aa98a0a7e7b7be081?d=identicon&s=25 Denis Defreyne (Guest)
on 2006-05-23 16:49
Hi.

I've been, fruitlessly, trying to extend the login code from the Agile
book. What I'm trying to do, is create a list of logged in users.

My idea is to the list of sessions. However, many sessions seem to be
outdated. I believe the best way would be to get a list of sessions that
have been active in, say, the last 15 minutes.

Question is: how can I do this? Any hints would be greatly appreciated.

Regards,

Denis Defreyne
E28c35323f624b8b9ed8712e25105454?d=identicon&s=25 Ray Baxter (Guest)
on 2006-05-23 18:59
(Received via mailing list)
Denis Defreyne wrote:

> My idea is to the list of sessions. However, many sessions seem to be
> outdated. I believe the best way would be to get a list of sessions that
> have been active in, say, the last 15 minutes.
>
> Question is: how can I do this? Any hints would be greatly appreciated.

Sessions aren't ActiveRecord objects, but for this purpose you can
pretend. Assuming you are storing your sessions in the database, get the
results with raw sql.

@active_sessions = ActiveRecord::Base.find_by_sql ["SELECT * FROM
sessions WHERE updated_at > ?", Time.now - 15.minutes]

I'd be interested in hearing how you get from this point to user ids.

--

Ray
This topic is locked and can not be replied to.