class CreateGrounddetails < ActiveRecord::Migration
def change
create_table :grounddetails do |t|
t.string :name
t.datetime :working_hours
t.string :address
t.string :contact_no
t.string :email
t.integer :no_of_ground
t.text :description
t.boolean :featured_ground #featured
t.timestamps null: false
end
end
end
我能夠從featured_ground
取true
值,但我有問題爲該特色地面設置一段時間。例如,將featured_ground
安排爲true必須在特定時間段內具有該特定地面,並且在該時間段之後應自動設置爲false。如何在rails中設置「特定時間段」?
缺少一些上下文。你可以在你的控制器或模型中做到這一點。 – ftshtw
或者你可以爲此設置「cronjob」,即。在一段時間後更新數據庫字段中的值。看看這個鏈接https://github.com/javan/whenever – chaitanya