Welcome to the Treehouse Community
Looking to learn something new?
How to assign 'users' to 'groups', Associations etc
Ok, so I've got a User model and a Group model.
User belongs_to :group
Group has_many :users, dependent: :destroy
Rather than CREATE a User from within a group, I want to create Groups (easy), and ASSIGN Users to Groups.
How do I do that?
Maciej Czuchnowski36,440 Points
I'm not 100% sure what your question is exactly, but:
1) Don't destroy the users along with the group! What if they want to join another group in the future when their current group is destroyed? Unless this is intended behavior.
2) What's your schema for groups and users? I want to show you a few examples of how to assign things both ways, if that is what you're asking ;)