开发者

acts_as_taggable_on find existing tags to suggest from content

开发者 https://www.devze.com 2023-04-08 17:51 出处:网络
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

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

精彩评论

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

关注公众号