module EducodeSales class Activity < ApplicationRecord belongs_to :staff has_many :activity_teachers, dependent: :destroy has_many :teachers, through: :activity_teachers, dependent: :restrict_with_exception has_many :manages, -> {where("educode_sales_activity_staffs.clazz_id = 0")}, dependent: :destroy, class_name: 'ActivityStaff' has_many :assists, -> {where("educode_sales_activity_staffs.clazz_id = 1")}, dependent: :destroy, class_name: 'ActivityStaff' has_many :experts , -> {where("educode_sales_activity_staffs.clazz_id = 2")}, dependent: :destroy, class_name: 'ActivityStaff' has_many :activity_staffs enum clazz_id: ['全国会议', '区域会议', '单校会议', '国赛', '省赛', '夏令营'] end end