2016-06-30 16:08:36 +08:00
|
|
|
|
class ApplyAddSchools < ActiveRecord::Base
|
2016-07-25 10:59:08 +08:00
|
|
|
|
# status:0 未审批 ; 1 已批阅
|
2016-06-30 16:08:36 +08:00
|
|
|
|
attr_accessible :address, :city, :name, :province, :remarks, :school_id, :status
|
2016-07-28 20:01:22 +08:00
|
|
|
|
has_many :applied_messages, :class_name =>'AppliedMessage', :as => :applied
|
2016-07-05 09:02:34 +08:00
|
|
|
|
belongs_to :school
|
2016-07-27 10:46:48 +08:00
|
|
|
|
|
|
|
|
|
after_create :send_massage
|
|
|
|
|
|
|
|
|
|
#给系统所有管理发送消息
|
|
|
|
|
def send_massage
|
|
|
|
|
users = User.where(:admin => 1)
|
|
|
|
|
users.each do |user|
|
|
|
|
|
self.applied_messages << AppliedMessage.new(:user_id => user.id, :viewed => false, :status => false)
|
|
|
|
|
end
|
|
|
|
|
end
|
2016-06-30 16:08:36 +08:00
|
|
|
|
end
|