What is the correct way to delete the records in a Join Table (used to
link two files using habtm).
I have resorted to creating a model for the join table. The table is
called boats_members (as it links two tables called boats and members.
And the model is called boats_member (to allow for rails pluralizing).
This way I can do Boats_member.delete_all which works just fine. (I am
also deleting all the records from the boats and members file prior to
rebuilding the whole thing). Because you do not normally need a model
for a join table I suspect there is a "more correct" way to delete the
I have tried using .clear but that did not delete the records in the
join table. I think what I tried was
b = Boat.find
but I have deleted the non-working code and I can't be sure. I'm
pretty sure I tried the .clear after had deleted the records in the
boats and members tables, in case that matters.
I am concerned that if junk remains in the join table it may
accidentally represent an incorrect join between unrelated records -
as well as which the join table might grow to an enormous size if it
cannot be cleared out.