Forum: Ruby on Rails RailsCron: 'every' in background

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
869f81abd180f09eafc22a662e5c9d18?d=identicon&s=25 Jake (Guest)
on 2006-02-23 08:43
(Received via mailing list)
Got another question.  It's unclear to me what "every" means in the
function and how it relates to the RailsCron.create "every":


      :command => "Object.do_something()",
      :start => 2.minutes.from_now,
      :every => 12.hours,               # default:
      :finish => 2.years.from_now       # optional

    class EmailQueue < ActiveRecord::Base
      background :deliver, :every => 1.minute, :concurrent => true

      def self.deliver
        #process the queue

It seems to me that the create method creates a job that runs every 12
If the command were "EmailQueue.deliver", I'd assume that the "deliver"
would run every 12 hours.

Then it confuses me that there's another every in the EmailQueue
call.  What exactly does background do?  And how does this "every"
interact with
RailsCron "every"?

4bd34a2216dc8bdbf1f017f64e4d59e8?d=identicon&s=25 Kyle Maxwell (Guest)
on 2006-02-23 19:10
(Received via mailing list)
On 2/22/06, Jake <> wrote:
>     )
> If the command were "EmailQueue.deliver", I'd assume that the "deliver" method
> Rails mailing list

Those code samples are different ways of doing the same thing.  A or
B, not A and B.  This difference is that background manages itself
through RailsCron.create_singleton, so that it autodetects changes to
your code.

Kyle Maxwell
Chief Technologist
E Factor Media // FN Interactive
This topic is locked and can not be replied to.