Forum: Ruby on Rails RE: how to insert Current DateTime value into database?

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.
Andrew Cherry (Guest)
on 2006-04-05 17:30
(Received via mailing list)
If you simply want the time that a record was updated, simply add a
field to the model table called "updated_at". It'll auto-update on save.
Larry W. (Guest)
on 2006-04-05 17:42
(Received via mailing list)
It's not rails-y, but I like having the db take care of this.  If you're
using migration maybe it doesn't matter, but if you're defining your
tables
first, then you could define them like so.

updated TIMESTAMPTZ NOT NULL DEFAULT NOW(),

 -- TIMESTAMPTZ is postgresql-specific I believe.

This covers you if you have ever have non-ruby/rails updates to the
table.

Is this basically what rails does under the covers?

thanks.
This topic is locked and can not be replied to.