Hello, in my app, I have users, groups, and grouproles. Each user can be a member of multiple groups. This I have achieved by imposing has_and_belongs_to_many relationship between users and groups (i.e. creating another table groups_users). However, each user should have a grouprole for each group he/she participates in. This means that for every user-group pair there should be a grouprole. Could you help me out with solving this, I don''t know how to add this relationship between users, groups, and gourproles. thanks :) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
What you need is a Membership model that associates a user to a group, instead of associating them directly using a HABTM association. The membership would point to the user, group and also contain that member role in the group. - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Thu, Feb 26, 2009 at 10:58 AM, Pesho Petrov <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Hello, > > in my app, I have users, groups, and grouproles. > > Each user can be a member of multiple groups. This I have achieved by > imposing has_and_belongs_to_many relationship between users and groups > (i.e. creating another table groups_users). > > However, each user should have a grouprole for each group he/she > participates in. > This means that for every user-group pair there should be a grouprole. > Could you help me out with solving this, I don''t know how to add this > relationship between users, groups, and gourproles. > > thanks :) > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
oh cool, that''s much more straightforward! Thanks Mauricio! Maurício Linhares wrote:> What you need is a Membership model that associates a user to a group, > instead of associating them directly using a HABTM association. > > The membership would point to the user, group and also contain that > member role in the group. > > - > Maur�cio Linhares > http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ > (en) > > > > On Thu, Feb 26, 2009 at 10:58 AM, Pesho Petrov-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---