Redundant Bidirectional Relationships in Rails Suck

2008-04-09 20:00:00 -0400

Update 06-JUN-2008: This plugin now includes acts_as_union, and we moved the repository to GitHub.

A better-late-than-never announcement: we released a Rails plugin a while ago that implements a better, DRYer way to roll network relationships using ActiveRecord. It's called, acts_as_network and it now updated to support Rails 2.0.

So why is this such a problem? It may not be immediately apparent, but the short answer is that these types of relationships usually require 2 redundant rows of storage in your database. Take a social network relationship: one record might say that Jack is Jill's friend, but a separate row must be present to say Jill is Jack's friend.

acts_as_network does away with this nonsense, and lets you say implicitly that If Jack is Jill's friend then Jill is Jack's friend. Or, in Ruby

# Jane invites Jack to be friends
invite = Invite.create(:person => jane, :person_target => jack, :message => "let's be friends!")

jane.friends.include?(jack) => false # Jack is not yet Jane's friend
jack.friends.include?(jane) => false # Jane is not yet Jack's friend either

invite.is_accepted = true # Now Jack accepts the invite and jane.reload and jack.reload

jane.friends.include?(jack) => true # Jack is Janes friend now
jack.friends.include?(jane) => true # Jane is also Jacks friend

The syntax is clean, and it stores only one row in your HABTM table. Online Documentation available or install/upgrade the plugin:

% script/plugin install git://
% rake doc:plugins

Much thanks to Maurycy for submitting patches to AAN!

Note: for a more in depth look at the acts_as_network syntax and usage please check out the original release page.

Tempo: Time Entry in Minutes

2008-04-07 20:00:00 -0400

We had an interesting request not too long ago for Tempo. Basically this user was accustomed to logging his time in minutes instead of hours. He found himself having to calculate 90 minutes into 1.5 hours to make new entries in our system, and asked us if there was some way to accommodate this other method.

It’s still a bit experimental at this stage, but if you put put an ‘m’ after the number in the hours box, it will get interpreted as minutes and converted for you by Tempo:

post in minutes

Minutes converted to hours

This also works when posting by e-mail. In addition, you can always use an ‘h’ after the number to clarify that you are submitting in hours if you wish.

New Mobile Features & Pricing for Tempo

2008-04-07 20:00:00 -0400

Since we launched Tempo a few weeks ago we’ve been hard at work adding new features to provide some of the mobile access we were looking for here at Zetetic.

The easiest to tackle was a mobile web interface for phones with data plans and iphones and such to have a quick and easy way to enter time. The screenshots in the tour give you a quick idea — it’s a miniature interface for logging your time on the go.

We also added a capability that allows you to record your hours by sending a simple e-mail. On every Tempo user’s account there is now an additional field called ‘alias’ that we set to something fairly random, but which you can change. Here’s how it works:

Let’s pretend my alias is super20x6. I could send the following e-mail to and it would get added to my time entries:

1.5 updated pl/sql stored procedure @bigco @oracle @plsql @development

This will create a new entry for one and a half hours, description ‘updated pl/sql stored procedure’, it will associate with my project BigCo, and it will be tagged with oracle, plsql, and development.

To find out more about how this capability works, skip on over to the new Mobile section in our FAQ.

Finally, we’ve made some adjustments to our pricing structure for premium plans. The big change is that all premium plans now provide unlimited projects (they still start at only $5 / month).

We’re definitely interested in hearing your thoughts on the new features and pricing. Leave comments here or email us at

Respect Is Due

2008-03-19 20:00:00 -0400

Throughout the course of building Tempo, we’ve relied heavily on software written by other people and made freely available. It’s worth doing a quick run-down to give credit where credit is due.

Ruby On Rails web application framework

No surprise there, right?

PostgreSQL relational database

Our favorite relational database system, Postgres is the most mature of the free systems out there, has the best feature set, and has quite a bit in common with Oracle. Highly recommended.

FamFamFam icons

Everybody needs icons, we’re big fans of the Silk set.

Acts As State Machine Rails plugin

This plugin by Scott Barron allows an ActiveRecord model to act as a finite state machine rather elegantly.

HAML & SASS HTML & CSS templating

Gone are the days when we painfully labor over HTML templates thanks to this great Rails plugin by Hampton Catlin. We can’t live without it now.

gchartrb Google Charts for Ruby

Those charts in Tempo look really good, but they’re largely the work of Google’s Chart API and this wrapper library for Ruby written by deepak.jois and aseemtandon. All we had to do was write some clever SQL and voila!

Active Merchant Rails plugin

Definitely the easiest way to integrate with a payment gateway in Rails. Also provides an awesome layer of abstraction in the event that we decide to switch gateways – we won’t have to do a major rewrite of the code in our site that handles payment processing.

Ruport Ruby Reports

Ruport made it incredibly easy for us to provide Excel/CSV and PDF exports from within Tempo’s WYSIWYG reporting interface.

RESTful Authentication Rails plugin

Very handy plugin by Rick Olson for quickly setting up an authentication system for your users that includes an activation step.

Thanks everyone for making these valuable open source contributions to make software like Tempo possible.

Tempo: Launch!

2008-03-17 20:00:00 -0400

Today marks the launch of our newest app, Tempo, a time tracking app for stats addicts, consultants, and anybody involved in professional services and billing time. The “beta” tag is gone, the gloves are off, the doors are open. Check out the tour to find out what it’s all about, sign up for a free account, let us know what you think (e-mail us: support AT zetetic DOT net). As our regulars know, we love hearing your suggestions.