From c465d3214fa7a7781eddb891b6e08b3e923bb1bd Mon Sep 17 00:00:00 2001 From: Cihangir SAVAS Date: Mon, 12 May 2014 12:52:47 +0300 Subject: [PATCH] set updated_at and created_at with the same timestamp, prevent record from having slight difference between fields --- callback_create.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/callback_create.go b/callback_create.go index e1b739e5..2f641b3d 100644 --- a/callback_create.go +++ b/callback_create.go @@ -13,8 +13,9 @@ func BeforeCreate(scope *Scope) { func UpdateTimeStampWhenCreate(scope *Scope) { if !scope.HasError() { - scope.SetColumn("CreatedAt", time.Now()) - scope.SetColumn("UpdatedAt", time.Now()) + now := time.Now() + scope.SetColumn("CreatedAt", now) + scope.SetColumn("UpdatedAt", now) } }