Acts As Most Popular

Make your models feel like they are in high school again. This plugin retrieves the most frequently occurring values for each column. It adds methods of the form most_popular_pluralized_column_name. You can control how many results you get with the :limit option. The default limit is 5.

=== Usage

class Exercise < ActiveRecord::Base
    acts_as_most_popular
end
class YourController < ActionController::Base
    def index
        @popular_exercises = Exercise.most_popular_names
    end
end

=== Notes

The most_popular_* methods take plural column names. Take a look at the tests for more examples.

=== Testing

Create a database named most_popular_test or change the database name in database.yml in the plugin folder. Navigate to the plugin folder and run rake.

Tags

Currently tagged with: acts_as
You need to Login to tag this item.