On 23 March 2012 16:48, bingo bob <[email protected]> wrote: > Colin Law wrote in post #1052938: >> On 23 March 2012 09:24, bingo bob <[email protected]> wrote: >>> "owned" by different users who may have it as a different position in >>> Freddy >>> Rod (3, male) >> A couple of questions >> Are all the Rod records identical except for which user they belong to? > > No they're not - for example one user might have rod as position 3 and > another user might love the name and have it as the number 1 choice. > >>> Freddy (2, male) >> >> What if one of the Freddys is female? Maybe not likely with this name >> but there are names that can be both. > > True - in my system the user simply designates a name as either M or F, > gender is an attribute of name...quite possible to have the same name as > both M and F and rightly so, actually current schema attached in case it > helps.
I think you would be better to have a join table, user_names maybe. Then have User has_many :user_names has_many :names, :through => :user_names UserName belongs_to :user belongs_to :name Name has_many :user_names has_many :users, :through => :user_names Have given and gender in names and the position in user_names I think that might help a lot. For example to find how many users have a name you can then just use @name.users.count. Colin -- 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.

