そう...
1)に accepted_at
フィールドがあります。このフィールドは手動で設定することもできます。それは「生きる時間」です。
2)
class Post
scope :ready_to_be_published, lambda{ where(['accepted_at<? and not published', Time.zone.now]).order('accepted_at ASC') }
def accept!(time_to_go_live = nil)
update_attributes!(:accepted_at => time_to_go_live || Time.zone.now)
end
end
3)午前10時と午後4時にrakeタスクを実行するには、いつでものジョブを持っている
task :publish_a_post => :environment do
Post.ready_to_be_published.first.update_attributes!(:published => true)
end