You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/models/ec_major_school.rb

20 lines
547 B

class EcMajorSchool < ApplicationRecord
belongs_to :ec_major
belongs_to :school
# 专业对应的学年
has_many :ec_years, dependent: :destroy
# 学校对应的专业中成员
has_many :ec_major_school_users, dependent: :destroy
has_many :users, through: :ec_major_school_users
scope :is_template, -> { where(template_major: true) }
scope :not_template, -> { where(template_major: false) }
# 是否为该专业管理员
def manager?(user)
ec_major_school_users.exists?(user_id: user.id)
end
end