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.rb

8 lines
373 B

6 years ago
class EcMajor < ApplicationRecord
# 主页对应的学校,不同学校可以选用同样的专业,而每个专业又各具特色
has_many :schools, through: :ec_major_schools
has_many :ec_major_schools, dependent: :destroy
scope :search_name_or_code, -> (keyword) { where('name LIKE :keyword OR code LIKE :keyword', keyword: "%#{keyword.strip}%") }
end