Created
May 18, 2009 20:47
-
-
Save jblanche/113733 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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