Skip to content

Instantly share code, notes, and snippets.

@jblanche
Created May 18, 2009 20:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jblanche/113733 to your computer and use it in GitHub Desktop.
Save jblanche/113733 to your computer and use it in GitHub Desktop.
# The main class
class League < ActiveRecord::Base
belongs_to :season
belongs_to :country
has_many :teams
has_many :games
def classify
teams.sort_by([:points, :goalaverage]).reverse
end
end
# Let's say that I create a League called "Strange"
# In this League the teams are ranked by their names
# I would like this League to extand the following Module
# So that I can call League.find(X).classify
# and have a classifying method per League.
module StangeLeague
def classify
teams.sort_by([:name])
end
end
# The 2 questions are :
# Is it the good way to do this
# If Yes, where and how should I call the extend method ?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment