站内信

先要建立modelrails g model notification。需要的column如下:

    t.string   "name"
    t.integer  "notifiable_id"
    t.string   "notifiable_type"
    t.datetime "read_at"
    t.integer  "recipient_id"
    t.integer  "trigger_id"

建立关系

notification的model
belongs_to :notifiable, polymorphic: true
belongs_to :recipient, :class_name => "User"
belongs_to :trigger, :class_name => "User"