Ransack query is returning wrong quantity of objects

I have this ransack query: SchoolTeacher.ransack(school_classrooms_id_eq: 1134).result.count

it should filter objects of SchoolTeacher where classroom_id os 1134. SchoolTeacher belongs_to School. School has_many Classrooms.

it should return 1 object, but returns 923, it is like the query is ignored and is returning to me all the objects of a certain school.

I tried to write this code using where, but returns the same quantity SchoolTeacher.joins(school: :classrooms).where(classrooms: { id: 1134 }).count

Upvotes: 0

Views: 55

Answers (0)

Related Questions