Ask A Question


You’re not receiving notifications from this thread.

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

Earl Greenwood asked in General

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:

I should definitely do a screencast on this stuff.

Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 82,160+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.

    Screencast tutorials to help you learn Ruby on Rails, Javascript, Hotwire, Turbo, Stimulus.js, PostgreSQL, MySQL, Ubuntu, and more.

    © 2024 GoRails, LLC. All rights reserved.