I'm having trouble trying to understand/wrap my brain around this. I'm trying to create a relationship that allows this:
- user can belong to many groups
- group can have many users
- a group has an owner which is a user
- the group ownership can be transferable
I've got the many-to-many relationship set up, but I can't seem to understand how to set up the ownership functionality.
here is what i have so far in my models:
class Group < ActiveRecord::Base
has_and_belongs_to_many :users
attr_accessible :name, :description, :isPublic, :tag_list, :owner
end
class User < ActiveRecord::Base
has_and_belongs_to_many :groups
attr_accessible :name, :description, :owner_id
end
Any help would be greatly appreciated!!