Howto get stuff to happen automatically?

I'm trying to get certain emails sent at a certain datetime.
So I have a column in my table called "due_by", as soon as it's overdue
is it possible to get an automatic email notification?

How do people get stuff like this to happen via. Rails without user
interaction?

TIA
Luke

You would need some sort of script that queues your table for any
email notifications that are due. An easy way to do this with your AR
models is to make a rake task which checks for any items due and sends
them.

You could have this run every 5 minutes or so using a cron job.

A more advanced solution might offload this to an external queue which
your script could poll from in an infinite loop.

Just some ideas...

Hmm, yeah I thought about just making it a cronjob, but I'm not too sure
if an external infinite loop is a good idea..

Is a cronjob the most common method of getting it done? or is there
something else that everyone uses?

backgroundrb lets you schedule ruby tasks like cronjobs.

It doesn't have to be a cron job. You can just have your app run an
infinite loop e.g.:

loop do
  # script code
end

and then manage this script with god. It'd be more responsive this
way.

A loop like that would have serious performance implications on the
server if it's hitting the database, checking a couple of values and
sending emails each trip wouldn't it?

Oh, btw Ryan, cheers for backgroundrb, that looks good. I might use
that.

eggie5 wrote:

"A more advanced solution might offload this to an external queue
which
your script could poll from in an infinite loop. "

How would that effect your local database?