class MessageAll < ActiveRecord::Base attr_accessible :message_id, :message_type, :user_id belongs_to :user # 虚拟关联---项目消息表/课程消息表/用户留言消息表/贴吧消息表 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'" belongs_to :message ,:polymorphic => true end