Created
June 4, 2014 19:27
-
-
Save Ross-Hunter/ea122684a5cbd1795083 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
| class User | |
| has_many :memberships | |
| has_many :groups, through: :memberships | |
| end | |
| class Membership | |
| belongs_to :user | |
| belongs_to :group | |
| end | |
| class Group | |
| has_many :memberships | |
| end | |
| ##Migration | |
| class CreateMemberships < ActiveRecord::Migration | |
| def change | |
| create_table :memberships, do |t| | |
| t.references :user_id, index: true | |
| t.references :group_id, index: true | |
| t.timestamps | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment