set updated_at and created_at with the same timestamp, prevent record from having slight difference between fields

This commit is contained in:
Cihangir SAVAS 2014-05-12 12:52:47 +03:00
parent 452123479e
commit c465d3214f
1 changed files with 3 additions and 2 deletions

View File

@ -13,8 +13,9 @@ func BeforeCreate(scope *Scope) {
func UpdateTimeStampWhenCreate(scope *Scope) { func UpdateTimeStampWhenCreate(scope *Scope) {
if !scope.HasError() { if !scope.HasError() {
scope.SetColumn("CreatedAt", time.Now()) now := time.Now()
scope.SetColumn("UpdatedAt", time.Now()) scope.SetColumn("CreatedAt", now)
scope.SetColumn("UpdatedAt", now)
} }
} }