Skip to main content

How do i implement a trending function like twitter or facebook on my rails app?

General • Asked by Earl Greenwood

I want to implement a trending function for last 24 hours hottest topic discuss or mentioned most in my website,i want to know is there anyway to implement this function in ruby on rails application?


Hey Earl,

What I would do is create an activity model, so you would keep track of the views, discussions, etc in a table, and then you can query for those within the last 24 hours and then count them up to determine which were the most active topics. You can query for the different types of activities and weigh some of those more than others (like comments might be more valuable than likes or something).

Does that make sense?

Here's a good article on how you could move that stuff into Postgres as a function: http://sorentwo.com/2013/12/30/let-postgres-do-the-work.html

I should definitely do a screencast on this stuff.


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 27,623+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.