I am new to ruby and ruby-on-rails. I need to implement complicated tagging engine:
each tag could have 0 or more synonyms (yep, just like on SO)
there should be an hierarchy of tags: i.e. there are sub-tags and super-tags. Say, I have three tags:
programming
,ruby
andc
. Then,programming
is a super-tag of bothruby
andc
, and when I enter tags for item about ruby, it's not necessary to enter tagprogramming
, I can only tag it withruby
. When I enter tags, all the super-tags should be added recursively. (actually it's strange I've never seen any tags engine with this feature, I really feel lack of it)each user should have its own set of tags, i.e. each
Tag
belongs_to
User
. Tags aren't public to anyone, they are private to its owner.
It seems I can't use acts_as_taggable_on
gem, right? So I have to implement my own one. Actually I have already implemented Tag
class that supports hierarchy, synonyms and users stuff, it seems to work. But there are a lot of questions how to make something taggable with it.
I am trying to reverse-engineer acts_as_taggable_on
, it is really complicated for a newbie like me..
So, there are a lot of questions, but I'm going to be more specific now:
Assume I have a class Item
that I want to be taggable. As far as I understand, I should use has_many :through
association, both on Item
and Tag
side. And therefore create intermediate table with item_id
and tag_id
fields.
BUT: I want my tagging engine to be universal! So I don't want to add to Tag
model anything related to Item
.
So, the only real question is: is it generally ok to create has_many :through
association only on Item
side?
And secondly, if anyone has some suggestions on the stuff I explained, I'd be happy to see them.