Pat Maddox
2006-May-07 03:12 UTC
[Rails] Can I find what time the current session was created?
I want to get the time at which the current session was created. It doesn''t have to be exact - I''m not worried about the fact that a user may not actually be on, yet the session is still active. I''d just like to be able to do session.created_at
Jeremy Kemper
2006-May-07 04:06 UTC
[Rails] Can I find what time the current session was created?
On May 6, 2006, at 8:12 PM, Pat Maddox wrote:> I want to get the time at which the current session was created. It > doesn''t have to be exact - I''m not worried about the fact that a user > may not actually be on, yet the session is still active. I''d just > like to be able to do > session.created_atWith the Active Record session store and a created_at timestamp column on the sessions table: session.model.created_at jeremy
Pat Maddox
2006-May-07 04:29 UTC
[Rails] Can I find what time the current session was created?
On 5/6/06, Jeremy Kemper <jeremy@bitsweat.net> wrote:> On May 6, 2006, at 8:12 PM, Pat Maddox wrote: > > I want to get the time at which the current session was created. It > > doesn''t have to be exact - I''m not worried about the fact that a user > > may not actually be on, yet the session is still active. I''d just > > like to be able to do > > session.created_at > > With the Active Record session store and a created_at timestamp > column on the sessions table: > session.model.created_at > > jeremy > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >hrm I tried that, but it''s always nil. I''m guessing that Rails doesn''t manage created_at since Session isn''t actually an AR model. *5 minutes later* I just set the default to be NOW() and it''s working fine. Had to use a custom execute statement though since the postgresql adapter is funky with setting default to NOW(). It''d be nice if I could get Rails to manage the created_at field for me somehow. Pat