Links
Acts As Most Popular
Categories
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.
Vitals
| Home | http://shanesbrain.net/articles/2006/08/04/acts-as-most-popular-rails-plugin |
|---|---|
| Repository | http://shanesbrain.net/svn/rails/plugins/acts_as_most_popular/ |
| License | Rails' (MIT) |
| Tags |
fg popular
|
| Rating | (4 votes) |
| Owner | Shane Vitarana |
| Created | 8 August 2006 |

