I am a Rails Newbie. I am trying to implement Hashtags in my project.
I have been looking at the following posts this and twitter gem.
This is my Tweets Controller:
def index
@tweets = Tweet.all
end
My Tweet Model
class Tweet < ActiveRecord::Base
include Twitter::Extractor
def extract_tags
extract_hashtags(self.post)
end
end
This is my View:
<% @tweets.each do |tweet| %>
<tr>
<td><%= tweet.post %></td>
<td><%= tweet.extract_tags %></td>
</tr>
<% end %>
In my browser.. this is what I see
#Rails is #awesome ["Rails", "awesome"] Show Edit Destroy
#37 Signals [] Show Edit Destroy
Ruby on #rails ["rails"] Show Edit Destroy
How do I combine all these individual array of hashtags into one big array?
How do I also display the most popular ones over a period of time.. lets say popular for the past 15 minutes, 1 hr etc.
Looking for help. Thanks a lot in advance!
You can get all tags from all tweets in one array like this:
If you don’t want repeated tags, add
uniqin the end.