如何在user.rb中添加依赖项:: destroy以使用邮箱破坏用户之间创建的邮件?
我有这些表格和列。
| id |主题| created_at | updated_at |
| id |类型|身体|主题| sender_id | sender_type | conversation_id |草稿| notification_code | informed_object_id | informed_object_type |附件| updated_at | created_at |全球|到期| sender_name |
| id | receiver_id | receiver_type | notification_id | is_read |遗骸|删除| mailbox_type | created_at | updated_at |
我做了
(user.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"
但它没有用。
答案 0 :(得分:0)
您必须在关联的belongs_to部分使用SftpFileStream.Write
。
因此,用户dependent: :destroy
和通知模型中应该说has_many :notifications
因为现在它说,如果有人删除通知,用户也将被销毁。