Module: EloRankable::HasEloRanking
- Defined in:
- lib/elo_rankable/has_elo_ranking.rb
Defined Under Namespace
Modules: InstanceMethods
Instance Method Summary collapse
Instance Method Details
#has_elo_ranking ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/elo_rankable/has_elo_ranking.rb', line 5 def has_elo_ranking # Set up the polymorphic association has_one :elo_ranking, as: :rankable, class_name: 'EloRankable::EloRanking', dependent: :destroy # Include instance methods include InstanceMethods # Add scopes for leaderboards scope :by_elo_rating, -> { joins(:elo_ranking).order('elo_rankings.rating DESC') } scope :top_rated, ->(limit = 10) { .limit(limit) } end |