Say I have a Student
model and a Class
model, and
Student.belongsToMany(Class, through: {StudentClasses})
.
In the DB, StudenClasses
table has id
, student_id
, class_id
, and id like to have all the associated student_id
s of a Class
instance by that table
How can I have on my Class
model an array containing all of the associated Student
IDs?
I've been struggling for a few days now, any help would be much appreciated!