Get taggable like all the cool kids

Posted by admin, August 27, 2005 @ 9:00 am

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.