在 Rails 4.2 项目中,我gem 'permanent_records'
用来处理记录软删除和gem 'globalize'
翻译。
Globalize 在翻译后的模型和翻译模型(source)之间设置以下关系:
has_many :translations, :class_name => translation_class.name,
:foreign_key => options[:foreign_key],
:dependent => :destroy,
:extend => HasManyExtensions,
:autosave => true,
:inverse_of => :globalized_model
结果是调用:destroy
翻译后的模型并没有删除它(这是使用 Permanent_records 的),但我丢失了相关的翻译,我想保留它。
我应该dependent: :destroy
只在某些翻译模型(我使用permanent_records的翻译模型)上覆盖回调吗?如何正确地做到这一点?
有没有其他方法可以得到想要的结果?