Consultation on the Activerecord

Asked

Viewed 89 times

0

I have this relationship

teste.

How do I consult on ActiveRecord to return data from Works, WorkZei and Wi_schools?

I tried so:

r = Responsible.find(1)

students = r.students

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

Results in the following error:

NoMethodError: undefined method `joins'
  • Can you give more details of your problem? it’s easier to help. In your case will really give error, why school is an object and not an Activerecordassociation so it makes no sense you make joins there. ! :)

1 answer

2

Responsible.where(id: 1).joins(students: [ school: [ :works, :work_zeis ] ]).first

Browser other questions tagged

You are not signed in. Login or sign up in order to post.