ActsAsRrranking
A rails plugin use redis to sort models on real time.
Example
class Player < ActiveRecord::Base
acts_as_rrranking :ranking, score: :game_point
end
Arguments
name
the name of the ranking field
options
| score | the field which the models can be sorted by (default: :score) |
| id | the identification field of the models (default: :id) |
Helper Methods
Suppose the name is :ranking and the score field is :game_point then the following methods will be generated:
| #current_ranking | return the current ranking |
| #update_ranking(score) | update the score to redis, also will be invoked in the after_save hook |
| ::top_rankings(limit, offset) | return the array of top ids |
| ::top_ranking_player(limit, offset) | return the array of top models |


