Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implementing twitter-like hashtag on rails

I'm want to implement twitter-like hashtag on my app.

Let's say I have user input to a text area "I'm coming to #london from #paris" then I want to build tag cloud of the hashtags.

I'm thinking of using acts-as-taggable-on. So I find all of my hashtags from the text in the backend, then save it to tag field.

Anyone has experience on this they would like to share? Thanks.

like image 388
tipbis Avatar asked Mar 15 '11 03:03

tipbis


1 Answers

Yes, ActsAsTaggableOn should be fine. As @etang alluded to, it's a heavy gem, but it gets the job done. If you're looking for a simple way to extract tags from text, you may want to look at https://github.com/twitter/twitter-text-rb. It has some nice regexps that may save you some time.

Twitter::Extractor.extract_hashtags("my #favorite #site is http://foo.com/home#boo")

That would return "favorite" and "site" but not "boo" (as would be expected).

like image 127
Adam Rubin Avatar answered Oct 02 '22 04:10

Adam Rubin