Rails set default DateTime to now

前端 未结 5 1190
Happy的楠姐
Happy的楠姐 2021-01-06 00:42

In my app I have teams and each team has a game time every week. I want the game times to be set to \'now\' as a default. My table is set up like so

create_         


        
5条回答
  •  梦毁少年i
    2021-01-06 00:58

    for Postgresql :

    add_column :users, :msgs_seen_at, 'TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP'
    

    but you'll have to use user.reload after user = User.create in order to "see" msgs_seen_at

提交回复
热议问题