I'm pretty newb and trying to get a handle on setting up a particular
relationship with my models.

For sake of this discussion (real app isn't with tools but for illustration,
using tools):

To start with (more complicated in a bit);

- A User can have multiple tools
- A single tool can only belong to one ToolGroup
- A User can belong to multiple ToolGroups

To model this relationship, I was thinking:

User
  has_many :tools
  has_and_belong_to_many :tool_groups

Tool
  has_one :tool_group
  belongs_to :user

ToolGroup
  has_and_belongs_to_many :users


So first question, is the above set up correctly?

Once the above is set up correctly, I want to have it set up where a
ToolGroup can also be 'owned' by a User. In other words, a user will set up
a ToolGroup and they are the owner, but other users can belong to this
ToolGroup. How do I model that? Do I need to set up another model that is
called "Owner" that is really a "User"? This doesn't seem right. In reality
the db table "ToolGroup" would just need an "ownerID" that would be a fk to
the User table, but I'm not sure how to model that since ToolGroup already
has a HABTM to users. Can I have a HABTM to Users and also a belongs_to
:User?

Thanks for any help

-- 
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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to