Plugins - Acts As Most Popular

StarAdd to favorites

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.

Shane Vitarana

http://shanesbrain.net/articles/2006/08/04/acts-as-most-popular-rails-plugin

http://shanesbrain.net/svn/rails/plugins/acts_as_most_popular/

Rails' (MIT)

  • Currently 5.0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Model

Tags

Comments

Add a comment

Search Plugins

Query syntax

Plugins by Category

Sponsors

Rails Kits: Get Code. Get Moving.

Have a comment?