class HomeworkBank < ApplicationRecord # homework_type: 1:普通作业 2:编程作业(弃用) 3:分组作业 4:实训作业 belongs_to :course_list belongs_to :homework_common, optional: true belongs_to :user has_many :attachments, as: :container, :dependent => :destroy has_many :homework_commons, dependent: :nullify scope :is_public, -> { where(is_public: true)} scope :myself, ->(user_id) { where(user_id: user_id)} end