Re: sessions

Frederick Cheung
Tue, 22 Jul 2008 20:20:35 -0000

On 22 Jul 2008, at 20:46, Justin To wrote:

>
> If I set every user''s session[:user_id] = user.id (model
object.id)
> and
> saved it in activerecord table sessions, how would I extract
> everyone''s
> session[:user_id] from the sessions table, so I can display who''s
> online?

with difficulty - the database just contains a Marshal.dump
representation of the data, so you can''t query for it.
You''d probably be better off just updating the users table with a
''last_seen_at'' timestamp. Or add a user_id column to the
sessions
table (access it via session.model if i recall correctly).

Fred
>
>
> Or is there a better way?
>
> Thanks!
> --
> Posted via http://www.ruby-forum.com/.
>
> >