Merge pull request #112 from siesta/timenowset

set updated_at and created_at with the same timestamp
This commit is contained in:
Jinzhu 2014-05-12 18:27:13 +08:00
commit 2f8b1842d8
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)
} }
} }