socialforge/app/models/apply_add_schools.rb

17 lines
539 B
Ruby
Raw Normal View History

class ApplyAddSchools < ActiveRecord::Base
2016-07-25 10:59:08 +08:00
# status0 未审批 1 已批阅
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
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
end