ActiveRecord query with multiple joins not recognizing the relations
问题 I am trying to write an ActiveRecord Query that returns all students enrolled in a certain course with the following query: def self.students_enrolled_in(course_id) Student .joins(:enrollments) .joins(:sections) .joins(:courses) .where(sections: { course_id: course_id }) end the result in the rails console is: ActiveRecord::ConfigurationError: Can't join 'Student' to association named 'sections'; perhaps you misspelled it? it seems that the association is made. what am I doing wrong? does the