socialforge/app/models/apply_add_schools.rb

17 lines
539 B
Ruby
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class ApplyAddSchools < ActiveRecord::Base
# status0 未审批 1 已批阅
attr_accessible :address, :city, :name, :province, :remarks, :school_id, :status
has_many :applied_messages, :class_name =>'AppliedMessage', :as => :applied
belongs_to :school
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