开发者

acts_as_taggable_on find existing tags to suggest from content

We're using the (brilliant) acts_as_taggable_on Rails gem, allowing users to add tags to content they write (e.g. blog comment).开发者_开发百科 We auto-suggest on as they type, but would also like to identify tags that we can suggest based on the user's content.

So if the user typed "We really loved the aquarium in Boston" and we had existing tags for "boston" and "aquarium" we might suggest those.

I think this is simple conceptually (iterate words, check the tags list, order by frequency of use), but there are little nuances, performance implications, and well, you know -- always harder than it looks.

Any suggestions for existing code or examples that might help me avoid recreating a wheel?

Thanks!


Well, I don't really know acts_as_taggable... But I think you can use something like :

  Tag.find(:all, :conditions => { :name => title.split(' ').map(&:downcase) })
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜