Created
September 21, 2015 21:26
-
-
Save smathy/dc091599444975cf6414 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 Car | |
has_many :cross_sections, as: :collectible | |
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 Collection | |
has_many :cross_sections | |
has_many :collectibles, through: :cross_sections | |
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 CrossSection | |
belongs_to :collectible, polymorphic: true | |
belongs_to :collection | |
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 User | |
has_many :collections | |
has_many :favorites, -> { collections.where type: "Favorite" } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment