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.
pgfqe6ch8/app/models/department.rb

17 lines
587 B

6 years ago
class Department < ActiveRecord::Base
belongs_to :school
has_many :department_members, :dependent => :destroy
# apply_add_departments 不能关联删除 tidings表有关联
has_many :apply_add_departments
has_many :tidings, as: :container, dependent: :destroy
6 years ago
attr_accessible :name, :school_id, :is_auth, :identifier, :is_delete
6 years ago
scope :is_active, lambda{where(:is_delete => false)}
scope :is_delete, lambda{where(:is_delete => true)}
# 如果 identifier 字段存在就取identifier 否则取id
def to_param
self.identifier.present? ? identifier : id
end
end