I understand HABTM relationships in Rails, but I can't figure out for
the life of me how to actually use them. For example, if you have (as I
do) two tables: "people" and "projects," then you need a third table,
"people_projects," to act as intermediary. You also need to declare
"has_and_belongs_to_many" in each of the two models.
I am in the middle of getting to grips with many-many in AR.
Now, having done all that, how would you actually create an association,
using a form?
If I want to put "Person A" on "Project B," then you would need Person
A's Person.id, and Project B's Project.id, right? But which model do you
update with the form? Do you send it to Person or Project?
They key thing is that the relationship is two-way, so person.projects
is as valid as project.persons << new_person are both valid. Its the choice that
is giving the confusion.
And when you're writing the form fields, how do you set up the data to
Sorry, can't help you with views, I am Camping on ActiveRecord.