Last active
May 12, 2016 16:21
-
-
Save Ross-Hunter/fc65bc87c1f57f34ed18 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_and_belongs_to_many :groups | |
end | |
class Group | |
has_and_belongs_to_many :groups | |
end | |
##Migration | |
class CreateUsersGroupsJoinTable < ActiveRecord::Migration | |
def change | |
create_table :users_groups, id: false do |t| | |
t.integer :user_id, index: true | |
t.integer :group_id, index: true | |
end | |
end | |
end | |
user.groups | |
group.users |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment