Best way to create a reminders system (like backpack's)

Hey all,

I have some idea’s floating around in my head and I’d like any opinions
on the best way to go about it and how to do it.

I’m basically wanting to create a simple reminders system in my apps.
Ideally it would be something similar to backpacks reminders, though
now all I’m looking for is just email alert functionality.

The process for the user I want to be as simple as:

1.) Click create
2.) Enter title, reminder note, due date and reminder (i.e 1 hour
before, 1 day before, 1 week before etc…)
3.) Click save

(#4 in the future) Email gets sent out based on when they want the
reminder.

What I’m trying to figure out is how best to “poll” the table rows of
saved reminders to send out the actual emails in an accurate way. Do I
use something like backgroundrb? Do I make a method that scans the db
once a day via cron and “schedules” the reminders coming up to send out
via ActionMailer? I don’t know how they designed the system in
backpack but I wouldn’t think it would be too hard.

Thanks for any ideas or advice in advance.

Hi Marston.

Best bet I would think would be to set up a daemon that runs, say, every
5 minutes. It would simply look at the table to see if any reminders are
due to be sent out within the next 5 minutes.

Using a daemon is the only realistic way of getting this to work well.
Depending on the load you daemon implementation imposes on your server,
you could even run it every 30seconds or so.

When it comes to making a daemon in Rails, I’ve found the best thing is
to use Kyle M.s Daemon Gem and Plugin. Basically this allows you to
run code within your rails environment (So it has access to your models
etc), and control them easily from the command line (./script/daemons
start, stop, restart etc). The best place to start out is reading the
posts and comments about it and the deprecation of its predecessor at
“his
blog”:Every Student: Rails Plugin

I recently used this to allow my
“blog”:http://douglasfshearer.dyndns.org/ to poll flickr to see if any
new images had been added. This runs once every hour, which is more than
enough for the task at hand. Setup is a little fiddly, as his docs
aren’t great (read the comments in his posts), so I plan to get round to
writing an install guide for it.

Hope this helps.

Dougal.

Douglas S. wrote:

Setup is a little fiddly, as his docs
aren’t great (read the comments in his posts), so I plan to get round to
writing an install guide for it.

I was motivated enough to actually write my guide, check it out here:
http://douglasfshearer.dyndns.org/blog/cron-jobs-in-ruby-on-rails

Cheers.

Dougal.

I believe the new version of BackgrounDrb has a scheduler task built
into. According to Ezra’s page ‘The new release comes with a brand new
job scheduler. You can use simple triggers like repeat_every or you can
get more complex and use full cron compatible syntax.’

I haven’t used it so I can’t say how well it fits your needs. It may
be a good Ruby based alternative to cron.

http://brainspl.at/articles/2006/10/30/backgroundrb-0-2-0-released

excellent guys, thanks for the info. I will definitely check it out.

Another option I was thinking about after checking out all this stuff
was perhaps to just write a single method to do it all and put a runner
that calls it in cron and have that set for every 5 minutes or so.

But from a efficiency and simplicity standpoint are there some bad
points to that idea?