【发布时间】:2016-09-09 08:19:33
【问题描述】:
如何在 user.rb 中添加 depentent: :destroy 来销毁使用mailboxer创建的用户之间的消息?
我有这些表格和列。
|邮箱对话 |
|编号 |主题 | created_at |更新时间 |
|邮箱通知 |
|编号 |类型 |身体 |主题 |发件人 ID |发件人类型 |对话ID |草稿|通知代码 | notify_object_id |通知对象类型 |附件 |更新时间 | created_at |全球 |过期|发件人姓名 |
|邮箱收据 |
|编号 |接收者 ID |接收器类型 |通知ID | is_read |垃圾|已删除 |邮箱类型 | created_at |更新时间 |
我做到了
(用户.rb)
has_many :messages, :class_name => "Mailboxer::Message", :as => :sender
has_many :receipts, -> { order(:created_at => :desc, :id => :desc) }, :class_name => "Mailboxer::Receipt", dependent: :destroy, as: :receiver
has_many :notifications, -> { where( notified_object_type: 'Assignment') },
foreign_key: "notified_object_id", dependent: :destroy,
class_name: "Mailboxer::Notification"
但是没有用。
【问题讨论】:
标签: ruby-on-rails