class SubDiscipline < ApplicationRecord belongs_to :discipline has_many :tag_disciplines, -> { order("tag_disciplines.position ASC") }, dependent: :destroy has_many :sub_discipline_containers, dependent: :destroy has_one :hack has_many :shixun_tag_disciplines, -> { where("shixun = 1") }, class_name: "TagDiscipline" has_many :subject_tag_disciplines, -> { where("subject = 1") }, class_name: "TagDiscipline" has_many :question_tag_disciplines, -> { where("question = 1") }, class_name: "TagDiscipline" validates_presence_of :name end