views:

33

answers:

1

I'm using Ruby on rails 2.3.8 and acts_as_taggable_on plugin. This plugin generates three tables: tags(which has the id and name of each tag) and taggings(relates tag_ids which the items that are tagged).

Now, I'd like to get all the items tagged with a certain tag_id. So, I go to my Announcement model(the announcements are the tagged items) and I'd like to write something like this:

def find_by_category(tag_id)
  Announcement.tagged_with(tag_id) #this doesn't exist.
end

But the only method I found actually was this:

Announcement.tagged_with(tag_NAME) #this works, but I don't want to find by a name.

Does anybody know a method to accomplish this, or at least, how to modify the plugin's code to do this?

A: 

acts_as_taggable has a method

Model.find_tagged_with @tag_name

That works for me in a couple of projects.

Method docs

Jesse Wolgamott