On 24 June 2013 13:54, Cameron Gilroy <m...@camerongilroy.com> wrote: > Hi > > I'm working on a project that has users and groups, users can be members of > a group or they can just be a user - what's going to be the best way to deal > with this?
If the user can only be a member of one group then use User belongs_to group. If a particular member does not belong to a group then just leave group_id nil. You will obviously have to allow for user.group == nil in the code where appropriate. If he can belong to many (or no) groups then use has_many :through as Dave suggested. You can test user.groups to see if he is in any groups. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLt99XE6J1YK%2BGk-rjM_JMAt%2BtbZpWrsZ%2BFd%3D%3DkfWx0srA%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.