我正在使用Paranoia寶石,現在正在與問題糾纏在一起。我需要加入has_many
已刪除的項目,但它不會被刪除。我的模型:Paranoia寶石 - 加入已刪除的項目
class Mailing < ActiveRecord::Base
acts_as_paranoid
has_many :mailing_fields
has_many :fields, through: :mailing_fields
end
class MailingField < ActiveRecord::
belongs_to :mailing
belongs_to :field
end
class Field < ActiveRecord::Base
has_many :mailing_fields, dependent: :destroy
has_many :mailings, through: :mailing_fields
end
查詢我運行應與已刪除項目返回mailings
:
Field.joins(:mailings).where('mailings.id = ?', mailing_id)