socialforge/app/models/message_all.rb

16 lines
1.1 KiB
Ruby
Raw Normal View History

2015-08-24 23:53:28 +08:00
class MessageAll < ActiveRecord::Base
attr_accessible :message_id, :message_type, :user_id
2017-01-12 16:19:11 +08:00
belongs_to :user
2015-08-24 23:53:28 +08:00
# 虚拟关联---项目消息表/课程消息表/用户留言消息表/贴吧消息表
belongs_to :forge_message, foreign_key: 'message_id', conditions: "message_alls.message_type = 'ForgeMessage'"
belongs_to :course_message, foreign_key: 'message_id', conditions: "message_alls.message_type = 'CourseMessage'"
belongs_to :applied_message, foreign_key: 'message_id', conditions: "message_alls.message_type = 'AppliedMessage'"
belongs_to :at_message, foreign_key: 'message_id', conditions: "message_alls.message_type = 'AtMessage'"
belongs_to :memo_message, foreign_key: 'message_id', conditions: "message_alls.message_type = 'MemoMessage'"
belongs_to :org_message, foreign_key: 'message_id', conditions: "message_alls.message_type = 'OrgMessage'"
belongs_to :system_message, foreign_key: 'message_id', conditions: "message_alls.message_type = 'SystemMessage'"
belongs_to :user_feedback_message, foreign_key: 'message_id', conditions: "message_alls.message_type = 'UserFeedbackMessage'"
2015-08-24 23:53:28 +08:00
belongs_to :message ,:polymorphic => true
2015-08-24 23:53:28 +08:00
end