Rails set default DateTime to now

前端 未结 5 1072
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条回答
  •  有刺的猬
    2021-01-06 01:02

    Since Rails 5 you can make a migration like this:

    change_column_default :users, :wk1_time, -> { 'CURRENT_TIMESTAMP' }
    

    In my mind this is the best option because it not database specific answer.

提交回复
热议问题