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.
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-05-07 05: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
24d2f8804e6bb4b7ea6bd11e0a586470?d=identicon&s=25 Jeremy Kemper (Guest)
on 2006-05-07 06:09
(Received via mailing list)
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
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-05-07 06:30
(Received via mailing list)
On 5/6/06, Jeremy Kemper <jeremy@bitsweat.net> wrote:
>
> 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
This topic is locked and can not be replied to.