My HABTM joins seem to be working for the most part. Yes! Now I’m trying
to create two lists on my project page of joined and unjoined contacts.
To list the contacts that are joined to my project I use:
<% mycontacts = @project.contacts %>
then use a for loop to display a checkbox next to each record so I can
select it to un-join them.
I’m stumped on how to list contacts that are not joined though. I’d like
to have checkboxes next to them so they can be added to the joined list.
Eventually I also hoping to have multiple lists of un-joined contacts
for contractors, developers, designers, and such which can be added to
the project (filtering the not joined contacts by role).
This starts to work when first loaded but then after addding contacts it
no longer discriminates and trying to unjoin previous selections stops
working. Hard coding the project_id won’t work in the final also:
<% mycontacts = Contact.find(:all, :joins => ‘INNER JOIN
contacts_projects ON contacts.id != contacts_projects.contact_id WHERE
(contacts_projects.project_id = 3 )’ ) %>
Any help appreaciated. Maybe there are some more in-depth HABTM
tutorials posted somewhere?