samedi 29 juillet 2017

Multiple one to many association for a single model

I have four models: Interview, Interviewee, Interviewer and InterviewDate.

The relations in terms of rails associations are as follows:

  1. An InterviewDate can have many Interviews (One to Many)
  2. An Interviewee can have many Interviews (One to Many)
  3. An Interviewer can have many Interviews and an Interview can have many Interviewers (Many to Many)

So, as you can see there are three incoming "Many" relations on the Interview model. How should the routing be done in rails given that I need to perform following tasks in the view ?

  1. List all Interviews grouped by InterviewDate

  2. Form for creation of an Interview (which would also include saving fields from other 3 tables into the database).

Aucun commentaire:

Enregistrer un commentaire