Adding a New Feature to Tracks: Email Todos From Certain Contexts

After searching long and hard for a good todo list manager, I finally settled on Tracks. It is fast, easy to use, and it is specifically designed with the “Getting Things Done” methodology in mind. Furthermore, it’s written in Ruby on Rails, which makes it fairly easy to add new features.

I have added one such feature to my copy of Tracks. One of the keys of a good productivity system is the ability to have the information you need when you need it. For example, a shopping list that you leave at home is useless. Likewise, a list of things you need to do while you’re out doing errands doesn’t do you any good if it’s stuck in your computer.

The ideal situation for me is to have the todos from contexts like @phone and @errands with me on my Blackberry wherever I go. Now, the volunteers who write Tracks are working on a version of the software that will be accessible by mobile phones, but that won’t help me. Since I run my copy of Tracks locally on my computer instead of on a web server, my phone would be unable to access Tracks.

The same problem affects solutions that involve Tracks’ built-in RSS feeds: feed readers that I could use wouldn’t be able to access them. After struggling—and failing—to get RSS-to-Email python scripts working (curse you AT&T for blocking port 25!), I finally struck upon an idea: Why not have change Tracks to have it automatically email my Blackberry the instant I create a task in these contexts?

In the extended entry, I go into how I tweaked Tracks to add this feature, in case you want to do it too. I would just submit this to the Tracks team as a feature suggestion, but there is a bit of manual configuration that I don’t think it would be easy to add to the main program. Here’s how its done.

(All file locations below assume the Tracks root directory as “/”)

Please note that you must be running the latest beta version of Tracks for this to work properly, as it depends on things like tags that are only available in the SVN trunk version of Tracks. Also note that you’ll need to know how to apply a patch file; I recommend using TortoiseSVN for this purpose.

First, add these lines after line 25 of /config/environment.rb to configure your email server settings, editing with your email server information:

config.action_mailer.delivery_method = :smtp
config.action_mailer.server_settings = {
    :address    => "",
    :port       => 25,
    :domain     => "",
    :authentication => :login,
    :user_name  => "",
    :password => "passwordgoeshere"
config.action_mailer.raise_delivery_errors = true

Then, go to the Tracks root directory from the command prompt and type:

ruby script/generate mailer TaskMailer add

Rails will autogenerate most of the files that you need, including files that I’ve not added to the patch.

Then download and apply this patch file.

Next, customize which contexts and tags will trigger the mail function. By default, it sends emails only when you put a todo in the @errands or @phone contexts, or tag a todo with the tag “agenda.” These are lines 84-85 of /app/controllers/todos_controller.rb.

does_include_tag = params[:tag_list].index('agenda')
if todo_context_name == "@errands" || todo_context_name == "@phone" || does_include_tag != nil || params[:tag_list] == "agenda" then

Finally, you’ll want to adjust lines 15 and 16 of /app/models/task_mailer.rb to change where the emails are being sent to and from. I have it sending to my Blackberry email address.

Restart the server and you should be good to go. You’ll notice a two or three second delay when adding todos that require sending an email. Your todo item will appear in your email a moment later.

It’s a bit of a hack, as it requires some hard-coded variables, but it works well enough for my needs. I can now carry an up-to-date @errands list with me wherever I go, and it gets to me automatically, with no further effort on my part.

My immense gratitude to Dave Thomas and David Heinemeier Hansson, authors of Agile Web Development with Rails (Second Edition), the book that taught me most of what I know about Rails.

2 thoughts on “Adding a New Feature to Tracks: Email Todos From Certain Contexts

  1. Cool. Thanks for sharing, JD. Another approach to this would be to use the after_create hook of the Todo model and perform your same logic there. You could implement this as a plugin that would live in your vendor/plugins directory. That would save yourself merging issues later.

    Cheers from NYC,