I want to build “groups” that users can join,
The flow of steps and things needed is in my head but the code to build this lacks some bit since I’m still learning rails. I would like to ask some advice on your ideas best practice of what would be needed to accomplish below:
- You can create a group with a name ‘test’
- You automatically join the group test, other users can join to
- If want to see a list of the users joined my group ‘test’
Im thinking of creating a model sessions like
groups|name|
But then how could I store the multiple users that are in this session?
Should I make an array of the user_id’s for example and make an extra column like
groups|name|user_ids ?
What would be best practice and what rails (3) methods could I use to get a very rough version of the above functionality up and running ?
From what I understand this is a many to many relationship. So you would have 3 models :
and to know what users belong to a group :
Update
to ensure the user creating the group also belongs to it :
of course the
current_usershould exist/be logged in with the usualbefore_filter(if I remember correctly itsauthenticate!with devise)