Want to stay on top? Ruby Weekly is a once-weekly e-mail newsletter covering the latest Ruby and Rails news.
     Feed Icon

acts_as_most_popular: Data popularity extension for Rails models

By Peter Cooper / August 8, 2006

Aamp

Shane Vitarana, creator of Rails Stats, has released a new plugin, acts_as_most_popular. acts_as_most_popular adds a method for each column in your model's table called most_popular_* that returns an array of the most popular entries within that column. For example, if you have 1000s of users in your user table, User.most_popular_names would return an array with the most popular names, as found in the name column.
Learn more here. This seems like the sort of thing that might eventually be useful as a Calculation of some kind.

Comments

  1. Shane Vitarana says:

    Good point about this being possibly useful as a Calculation. Popularity of a data set can also be seen as the mode of the data set in decreasing order. Calculations already has average, maximum, and minimum, so mode really isn't too much of stretch. The only hitch is that Calculations currently are only for numerical data. Thats the reason I made it an Acts As plugin. But it might be better suited as a Calcualtion. I'll look into it. Thanks for the tip!

  2. BillSaysThis says:

    Shane's site seems offline, or at least I've been getting 404s since reading this about five hours ago...

  3. Shane Vitarana says:

    Sorry, my server was offline on the 14th due to issues with my ISP.

Other Posts to Enjoy

Twitter Mentions