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.
21 lines
664 B
21 lines
664 B
class SystemMessage < ActiveRecord::Base
|
|
attr_accessible :content, :id, :user_id, :description, :subject
|
|
belongs_to :user
|
|
|
|
validates :subject, presence: true
|
|
# validates :description, presence: true
|
|
validates_length_of :description, maximum: 10000
|
|
|
|
has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy
|
|
acts_as_attachable
|
|
|
|
# 系统消息放置总消息列表
|
|
after_create :add_system_message
|
|
|
|
def add_system_message
|
|
if MessageAll.where("message_type = '#{self.class.to_s}' and message_id = '#{self.id}'").first.nil?
|
|
self.message_alls << MessageAll.new(:user_id => self.user_id)
|
|
end
|
|
end
|
|
end
|