diff --git a/app/controllers/departments_controller.rb b/app/controllers/departments_controller.rb index b6ebcb2ef..5e82b2c51 100644 --- a/app/controllers/departments_controller.rb +++ b/app/controllers/departments_controller.rb @@ -1,6 +1,6 @@ class DepartmentsController < ApplicationController def for_option - render_ok(departments: current_school.departments.select(:id, :name).as_json) + render_ok(departments: current_school.departments.without_deleted.select(:id, :name).as_json) end private diff --git a/app/models/department.rb b/app/models/department.rb index 15a8a7c1b..9c4a0908b 100644 --- a/app/models/department.rb +++ b/app/models/department.rb @@ -2,4 +2,6 @@ class Department < ApplicationRecord belongs_to :school has_many :department_members, dependent: :destroy + + scope :without_deleted, -> { where(is_delete: false) } end