English 中文(简体)
铁路3个博客中一个员额的预定出版
原标题:Schedule publishing of a post in a rails 3 blog

I m developing a website (with Rails 3.1) where limited set of writers are able to write post. Moderators should accept (or decline) the post and schedule the publishing. Until this moment is the development process pretty basic.

每天有两个出版时间。 接受的职位将安排在某种地点。 每天10时am和4时,必须公布最老的公认职位。 www.un.org/chinese/ga/president

What s the best way to achieve the result? Cron? Background Jobs?

最佳回答

因此

(1) 有一个“<条码>被接纳为领域,你也可以人工确定;它为生活的时间。

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) have a whenever job at 10am and 4pm to run a rake task

task :publish_a_post => :environment do
  Post.ready_to_be_published.first.update_attributes!(:published => true)
end
问题回答

暂无回答




相关问题
c# stack queue combination

is there in C# some already defined generic container which can be used as Stack and as Queue at the same time? I just want to be able to append elements either to the end, or to the front of the ...

Packet Queue in Python?

is there any way to queue packets to a socket in Python? I ve been looking for something like the libipq library, but can t find anything equivalent. Here s what I m trying to accomplish: Create ...

Java Queue Merge, Beginner

I m trying to write a method that will take in two Queues (pre-sorted Linked Lists) and return the merged, in ascending order, resulting Queue object. I pasted the Queue class, the merge method ...

Efficient queue in Haskell

How can I efficiently implement a list data structure where I can have 2 views to the head and end of the list, that always point to a head a tail of a list without expensive calls to reverse. i.e: ...

Thread & Queue vs Serial performance

I though it ll be interesting to look at threads and queues, so I ve written 2 scripts, one will break a file up and encrypt each chunk in a thread, the other will do it serially. I m still very new ...

Insert into an STL queue using std::copy

I d like to use std::copy to insert elements into a queue like this: vector<int> v; v.push_back( 1 ); v.push_back( 2 ); queue<int> q; copy( v.begin(), v.end(), insert_iterator< queue&...

Threading in Ruby with a limit

I have a task I need to perform, do_stuff(opts), that will take ~1s each, even while 1 - 10 of them are running in parallel. I need to collect an array of the results for each operation at the end. ...

热门标签