I am a bit new to rails and I want to create user groups in my application. A user can belong to many groups and a group can have many users in it. For instance there would be a first grade group with all first grade teachers in it and they will also belong to a number of other groups.
This is my current code.
class Group < ApplicationRecord
has_many :users
end
class User < ApplicationRecord
belongs_to :group
end
At the moment if I assign a user to a group in the Ruby console it only allows one group id. How can I make a user have multiple group_ids?
Membership
that has auser_id
and agroup_id
.