Forum: Ruby on Rails Can I find what time the current session was created?

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.
Pat M. (Guest)
on 2006-05-07 07:14
(Received via mailing list)
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 K. (Guest)
on 2006-05-07 08:09
(Received via mailing list)
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
Pat M. (Guest)
on 2006-05-07 08:30
(Received via mailing list)
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
This topic is locked and can not be replied to.