开发者

Good approach to a tagging system in Rails 3?

I'm trying to add tagging to my rails app - I'd rather not use a plugin/gem for this though.

My needs are pretty simple:

Users can add multiple tags to a single item, they can search for items by those tags, and they can see a page which lists all the tags they've used 开发者_开发问答before.

What I'm wondering is, whats the best way to go about this? An array/hash in the model being tagged? A join table?

Any suggestions would be highly appreciated.


I would use a join table between the tags and the taggableItems. Then with a before_create you could check if the tag's are already in the system and create them if they aren't in the system. Next you could use searchlogic (i think there is a rails 3 branch on github) for easy tag/taggableItems searching. And it would be nice to give the user some feedback of the available tags with some autocompletion or a short list of most used tags but that is up to you/the design.


Maybe this helps you: Best Rails Tagging Plugin/Gem

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜