2016-01-20 49 views
0
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_groundtrue值,但我有問題爲該特色地面設置一段時間。例如,將featured_ground安排爲true必須在特定時間段內具有該特定地面,並且在該時間段之後應自動設置爲false。如何在rails中設置「特定時間段」?

+0

缺少一些上下文。你可以在你的控制器或模型中做到這一點。 – ftshtw

+0

或者你可以爲此設置「cronjob」,即。在一段時間後更新數據庫字段中的值。看看這個鏈接https://github.com/javan/whenever – chaitanya

回答

2

可以在應用程序中設置「的cronjob」和特定的時間段後運行。 請通過以下鏈接,您可以找到有關如何使用「每當」寶石進行設置的解決方案。

https://github.com/javan/whenever

0

也許有時間戳featured_at字段替換布爾featured_ground場?這樣你就可以看到地面在一段時間內是否具有特色。

相關問題