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 :invitations , -> {where("educode_sales_activity_staffs.clazz_id = 3")}, dependent: :destroy, class_name: 'ActivityStaff' has_many :activity_staffs, dependent: :destroy has_many :activity_follow_ups, dependent: :destroy belongs_to :sales, class_name: 'Staff', optional: true has_one :attachment, as: :container, dependent: :destroy enum clazz_id: ['全国会议', '区域会议', '单校会议', '国赛', '省赛', '夏令营'] enum state_id: { '策划中': 1, '筹备中': 2, '实施中': 3, '已结束': 4, '已撤销': 5, '已推迟': 6 } end end