Created
March 19, 2013 20:28
-
-
Save nuclearsandwich/5199808 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
class Identity < ActiveRecord::Base | |
belongs_to :user | |
has_many :accounts | |
# relation logic methods. | |
end | |
class Account < ActiveRecord::Base | |
belongs_to :identity | |
end | |
class TwitterAccount < Account | |
end | |
class FacebookAccount < Account | |
end | |
class YoutubeAccount < Account | |
end | |
class User < ActiveRecord::Base | |
has_one :identity | |
def aggregate_social_nonsense | |
identity.aggregate_social_nonsense | |
end | |
end |
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
class BetterNameThanStageRelationForDescribingRelationshipBetweenIntakeAndStage < ActiveRecord::Base | |
belongs_to :intake | |
has_one :stage | |
has_many :demos | |
has_many :loans | |
has_many :releases | |
def each_by_date | |
# To the best of my knowledge there's no Ruby that can interleave these as they come from the database. | |
(demos.order_by(:date) + loans.order_by(:date) + releases.order_by(:date)).sort_by(&:date) | |
end | |
end | |
class Intake < ActiveRecord::Base | |
has_one :BetterNameThanStageRelationForDescribingRelationshipBetweenIntakeAndStages.underscored | |
end | |
class Demo < ActiveRecord::Base | |
belongs_to :BetterNameThanStageRelationForDescribingRelationshipBetweenIntakeAndStages.underscored | |
end | |
class Loan < ActiveRecord::Base | |
belongs_to :BetterNameThanStageRelationForDescribingRelationshipBetweenIntakeAndStages.underscored | |
end | |
class Release < ActiveRecord::Base | |
belongs_to :BetterNameThanStageRelationForDescribingRelationshipBetweenIntakeAndStages.underscored | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment