Created
March 19, 2019 19:32
-
-
Save mustmodify/a64d6994bbbcad6ca902d9b796652f65 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 initial way would be: | |
If you had a table clubs_people | |
int club_id | |
int person_id | |
class Club < ActiveRecord::Base | |
has_and_belongs_to_many :people | |
end | |
class People < ActiveRecord::Base | |
has_and_belongs_to_many :clubs | |
# Rails would assume a table named clubs_people unless you specified otherwise | |
end | |
# A more sophisticated way would be to create a memberships table, which might have meta-attributes like date joined. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment