Project

popstar3

0.0
No commit activity in last 3 years
No release in over 3 years
Popstar3 lets you add rules to determine your rails models popularity.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 3.0.0
~> 3.2.6
 Project Readme

Popstar3

Mongoid >= 3.0.0 support of Popstar repo


Popularity system for your Rails models.

Installation

Put this in your gemfile:

gem 'popstar3'

Usage

Define your badge rules in a PopularityRules class

class PopularityRules
  include Popstar3::Popularity

  def initialize
    popularity_for :voteable do
      on :create, Vote, :rate => proc { |vote| vote.rate*2 }
      on :update, Vote, :rate => proc { |vote| (vote.rate - vote.rate_was)*2 }
    end

    popularity_for :question do
      on :create, Answer, :rate => 2
    end

    popularity_for :viewable do
      on :create, ViewsCount
    end

    popularity_for :widget do
      on :create, Comment
      on :create, Question, :rate => 2
      on :create, Answer, :rate => 3
    end
  end
end

Supported ORMS

  • Mongoid >= 3.0.0

TODO

  • Add support for ActiveRecord
  • Add rake tasks to migrate popular models after defining rules