On 3 April 2010 15:32, RVRoadie [email protected] wrote:
Club has many Members
Person has many Members
That’s novel.
Possibly memberships would be a better name, or am I misunderstanding
what this table is for?
Members belong to Club, Person
You seem to have snipped the original question. I will have to get it
back from the earlier post.
On 2 April 2010 15:21, RVRoadie [email protected] wrote:
Kind of new at this and have been unable to find an example of what I
want to do.
I have three models, people, clubs and members.
@members = @club.members.all → finds all club members
In fact you can just use @club.members to give you all the members of
@club. Are you not more likely to want all the people that are
members of the club though?
If you also say club has_many people through memberships then you can
also @club.people to give you all the actual people.
How do I write a find of all people that are not members of @club
If you further have person has_many clubs through memberships then
person.clubs will give you all his clubs and to get the people who are
not members of @club you can do something like
person.find( :all, :include => :clubs, :conditions => [‘club.id <> ?’,
@club.id] )
That might not be quite right, but something like that.