Hello list, For a school management application, I've got three tables: - people - subjects - roles (e.g. 'Teacher', 'Student', 'Tutor', 'Lecturer', ...) The HABTM relationship is 3-way, with the links being stored in the people_roles_subjects table. A person can have a role in a subject, but may have different roles in different subjects - no person can have more than one role in each subject. Is it possible to use the Scaffolding Extensions plugin in this scenario to manage this HABTM data? Thanks in advance Dave M.
on 2006-02-01 09:21
on 2006-02-01 19:42
On 1/31/06, David M. <email@example.com> wrote: > have more than one role in each subject. > > Is it possible to use the Scaffolding Extensions plugin in this > scenario to manage this HABTM data? No, it's currently fairly prude, it couldn't cope with a 3-way. I'd look at the scaffold_habtm function in the plugin to get an idea of how to do what you want. If I were to add a 3-way scaffolding function (scaffold_3way), here's how I envision it working: The view for edit_person_subjects_roles would have 3 select boxes: - A multiple select box with all subjects - A multiple select box with all roles (in your case you might want this to be singular) - A multiple select box with the subject-role pairs that are already associated with the person Clicking on update would remove the subject-role pairs from the subject-role pairs select box, and add new subject-role pairs using the combination of subjects and roles selected from the subjects select box and the roles select box. The scaffold_3way function would create the following views which all would work similarly: edit_person_subjects_roles edit_person_roles_subjects edit_subject_people_roles edit_subject_roles_people edit_role_people_subjects edit_role_subjects_people There is significant additional complexity for three way relationships that you would need to work out, but it should be manageable. It sounds like a fun project, though I don't think there are nearly as many applications as there are for the regular habtm scaffolding. For bonus credit, you could further extend the idea to handle n-way scaffolding, which would be a real trip. Anyway, if you need any help, please let me know. If you get it working and want it added to the Scaffolding Extensions plugin, I'd be amenable to that. Jeremy