Dear List,

I'd welcome some opinions on a modeling challenge I have.

I'm working on a game-app.

Each user in this app has many friends.

Also the user has many enemies.

These friends and enemies are user objects.

So we have 2 possible HABTM (Has And Belongs To Many) relationships.

A user HABTM friends.
A user HABTM enemies.

But, I dont like HABTM.

I'd prefer to have a HMT (Has Many Through).

I think it might be typical that when I replace a HABTM with a HMT,
that I use a model with "Membership" in its name.

So for example, I might Have-Many-Friends in England.

So perhaps I'd have a FriendsLocationMembership model.

Or, I might  Have-Many-Enemies because I am a mutant.

So it looks like a Membership model could have an attribute name
"reason" which helps me understand why a particular user might be my
enemy or friend.

So it seems reasonable that I might have 2 or 3 groups of friends for
different reasons:

- I have money
- I am a good warrior
- I am trustworthy
etc...

Obviously the same goes for my enemies.

Also another question I need to answer is related to battles.

In any battle I'd like to know who are my friends and who are my enemies.

And of course if I see a friend/enemy I want to know who his friends
and enemies are.

I'm looking for help/ideas on how I might code up the associations in
the models and the syntax in the migrations.

What makes this difficult for me is I only see 2 models:

User
Membership

Or possibly 3 models:

User
FriendMembership
EnemyMembership

Do any of you think this is an interesting topic?

--Audrey

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

Reply via email to