I there some place that has a good walk through on implementing
tagging?
Basically, I have a table of things a table of tags. the things have a
many-to-many relationship to tags. I can get tags for a thing by
thing.tags but i’m at a loss as to how to get things back that are
tagged with multiple tags –
ie. if i were writing sql:
SELECT thing_id
FROM thing
JOIN thing_tag AS thing_tag_1 ON (thing.thing_id =
thing_tag_1.thing_id)
JOIN tag AS tag_1 ON (thing_tag_1.tag_id = tag_1.tag_id)
JOIN thing_tag AS thing_tag_2 ON (thing.thing_id =
thing_tag_2.thing_id)
JOIN tag AS tag_2 ON (thing_tag_2.tag_id = tag_2.tag_id)
WHERE tag_1.tag = ‘foo’
AND tag_2.tag = ‘bar’
Intersection (AND)
Query for “bookmark+webservice+semweb”:
SELECT b.*
FROM scBookmarks b, scCategories c
WHERE c.bId = b.bId
AND (c.category IN (‘bookmark’, ‘webservice’, ‘semweb’))
GROUP BY b.bId
HAVING COUNT( b.bId )=3
I currently use the acts_as_taggable plugin because I need to tag
stuff on multiple tables and if you use the gem version you need a
taggings tables for each one of those tables. So if you need to tag a
lot of different I’d go with the plugin, or else the gem which has
some goodies built-in like tags cloud.
Unfortunately, both seem to be have no more development at all
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.