How to reset boolean to “default: false” at end of day?

前端 未结 3 1369
梦如初夏
梦如初夏 2021-01-16 08:41

I have a boolean in the DB: t.boolean \"completed\", default: false

I ONLY show those still false on the home page.<

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-16 08:54

    You can create a rake task using whenever gem. Something like below should work

    every 1.day, :at => '12:00 am' do
      runner "YourModel.method_to_update"
    end
    

    And in your model, write a method like below

    def self.method_to_update
      YourModel.update_attribute(completed: false)
    end
    

提交回复
热议问题