Created
October 10, 2012 16:52
-
-
Save samiron/3866858 to your computer and use it in GitHub Desktop.
Rails 3: has_many :through
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
#FILE: models/user.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a complete demonstration of
many-to-many
relationship usinghas_many :through
between two models.Here we have
Team
andPlayer
models where each can contain many of other.Like, a team has many players and a player has many teams. They are related through
Contract
model which hasplayer_id
,team_id
andoffer
columns.The focus is to show