Saturday, August 27, 2005

Get taggable like all the cool kids

Posted by admin

Demetrius Nunes has a very cool acts-as mixin ready for you in a single line. It allows you to do stuff like:

class Photo < ActiveRecord::Base
  acts_as_taggable
end
 
elephant = Photo.find(4437)
elephant.tag 'zoo animals nature'
 
elephant.tagged_by?('urban') # => false
elephant.tags.size # => 3
elephant.tag_names => [ 'zoo', 'animals', 'nature' ]

Without any real effort at all. Neato. It’s pending as a patch too, so it’ll most likely make it into the next version.