Imagine I want to track people, and the clubs that they belong to.
table people with columns person_id, person_name
table clubs with columns club_id, club_name
And I have the association table:
table clubs_people with columns person_id, club_id
Now I know how to do this habtm between the two, in order to associate
people with clubs that they belong to.
However my application also needs a secondary association just like
this: imagine I want to track the clubs that a person has APPLIED to
join, but is not yet a member.
So I have a second association table
table clubs_people_applied with columns person_id, club_id
In other words, I need TWO habtm’s between the same two tables.
Where this is failing I think is in the model definitions:
Class Person < ActiveRecord::Base
has_and_belongs_to_many :clubs, :join_table => clubs_people
has_and_belongs_to_many :clubs, :join_table => clubs_people_applied
…
end
The rails api says that “WARNING: If youâ??re overwriting the table name
of either class, the table_name method MUST be declared underneath any
has_and_belongs_to_many declaration in order to work.”
Is this the problem? I don’t understand what this means exactly, that
is I don’t know how to declare the method.
Thanks!