Query in ActiveRecord

0

I have this relationship

.

How do I query on ActiveRecord to return data for Works , WorkZei and Wi_schools ?

I've tried it like this:

r = Responsible.find(1)

students = r.students

students.each {|s| s.school.joins(:works,:work_zeis).all }

It results in the following error:

NoMethodError: undefined method 'joins'
    
asked by anonymous 04.05.2016 / 22:57

1 answer

2
Responsible.where(id: 1).joins(students: [ school: [ :works, :work_zeis ] ]).first
    
05.05.2016 / 22:45