Created
February 25, 2013 05:08
-
-
Save anonymous/5027875 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
Track.last.authors => works | |
Track.last.original_author => doesn't work | |
User.last.creations => works | |
User.last.original_creations => doesn't work. | |
I'm still a beginner and not entirely sure how the relationships work, and which words need to match. For example, does "author" need to match in "belongs_to :author" from Track_Author with "has_many :authors" from Track.rb? |
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
#belongs to multiple authors | |
has_many :track_authors | |
has_many :authors, through: :track_authors | |
has_one :original_author, through: :track_authors, conditions: { track_authors: { author: true } } | |
#bookmarked users | |
has_many :track_users | |
has_many :users, :through => :track_users |
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
#authors track | |
has_many :track_authors | |
has_many :creations, through: :track_authors | |
has_many :original_creations, through: :track_authors, conditions: { track_authors: { author: true } } | |
#bookmarks track | |
has_many :track_users | |
has_many :tracks, :through => :track_users |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Temporarily solved by doing