« A well-targeted AdWords campaign | Main | Vishy's Indian English Dictionary: crib »
February 13, 2006
HOWTO: Make acts_as_taggable work with PostgreSQL
I recently had a chance to play with acts_as_taggable, a sweet little mixin written in Ruby for ActiveRecord/Ruby on Rails model classes that gets them associated with keywords (aka tags or metadata) with relatively little effort. This post won't be particularly useful unless you first read a basic tutorial about using acts_as_taggable.
My setup is centered around the PostgreSQL database product, even though MySQL is far more popular. When I followed the instructions in the tutorial above, I found that I was getting some fairly basic PostgreSQL errors which went something like:
column " posts.title" must appear in the GROUP BY clause or be used in an aggregate function: SELECT posts.* FROM tags_posts, posts, tags WHERE tags_posts.tag_id =
tags.id AND ( tags.name = 'voip') AND posts.id = tags_posts.post_id GROUP BY posts.id HAVING COUNT( posts.id) = 1
Apparently this is a known issue in the acts_as_taggable project's bug tracker but when I searched for a patch, one was not available. With lots of help from Goynang on #rubyonrails, I've put together a patch that would make acts_as_taggable work properly with PostgreSQL. Hopefully this will be integrated into the main project soon, but until then, use it for your needs. I impose no restrictions on the use of this patch especially considering very little of it is my code.
Posted by Vishy at February 13, 2006 09:33 PM