Can I find what time the current session was created?


#1

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


#2

On May 6, 2006, at 8:12 PM, Pat M. 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


#3

On 5/6/06, Jeremy K. removed_email_address@domain.invalid wrote:

jeremy


Rails mailing list
removed_email_address@domain.invalid
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