From 1c9765b4c1dbce5aabf520b54f769e4910d1f301 Mon Sep 17 00:00:00 2001 From: AnaPerola Date: Thu, 20 Jun 2024 16:47:59 -0300 Subject: [PATCH] Cria novo scope para filtrar turmas por id da escola --- app/models/classroom.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/classroom.rb b/app/models/classroom.rb index acdf4197d..f5ec16a74 100644 --- a/app/models/classroom.rb +++ b/app/models/classroom.rb @@ -41,6 +41,7 @@ class Classroom < ApplicationRecord } scope :by_unity, ->(unity) { where(unity: unity) } + scope :by_unity_id, ->(unity_id) { where(unity_id: unity_id) } scope :by_unity_and_grade, ->(unity_id, grade_id) { where(unity_id: unity_id).by_grade(grade_id).distinct } scope :different_than, ->(classroom_id) { where(arel_table[:id].not_eq(classroom_id)) } scope :by_grade, ->(grade_id) { joins(:classrooms_grades).merge(ClassroomsGrade.by_grade_id(grade_id)) }