Forum: Ruby on Rails Current date/time - how to store with comments?

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.
1e2dd87a31c5d3e07adc9efa375f4dc4?d=identicon&s=25 ry an (hreyaatnh)
on 2006-03-04 05:27
Can someone tell me how to store the current date/time when someone
posts a comment on my blog?  I could even update the comments table
after the comment is saved in the controller, but I'm not sure how to do
that either.

Thanks for any help...
42172acdf3c6046f84d644cb0b94642c?d=identicon&s=25 Pat Maddox (pergesu)
on 2006-03-04 05:33
(Received via mailing list)
Create a field called created_at and/or updated_at and Rails will do
it all automatically.  Make sure it's a datetime (that's in postgres,
not sure what the mysql equivalent is).

You can also just make a datetime field called whatever you want, and
do something like:
comment.posted_at = Time.now

and save it yourself..but it's easier/more railsy to just use the
"magic" fields created_at/updated_at.

Pat
1e2dd87a31c5d3e07adc9efa375f4dc4?d=identicon&s=25 ry an (hreyaatnh)
on 2006-03-04 05:34
Thanks, that was easy!
This topic is locked and can not be replied to.