From e8b0866ff0a41f389c323a6c60c50e91855e9b1f Mon Sep 17 00:00:00 2001 From: p31729568 Date: Thu, 25 Jul 2019 10:45:48 +0800 Subject: [PATCH] fix department show deleted --- app/controllers/departments_controller.rb | 2 +- app/models/department.rb | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) 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