class Profile < ApplicationRecord
acts_as_paranoid
has_many :degreeholderships
has_many :degrees, through: :degreeholderships, dependent: :destroy
end
class Degreeholdership < ApplicationRecord
acts_as_paranoid column: :active, sentinel_value: true
belongs_to :profile
belongs_to :degree
validates :profile_id, presence: true
validates :degree_id, presence: true
def paranoia_restore_attributes
{
deleted_at: nil,
active: true
}
end
def paranoia_destroy_attributes
{
deleted_at: current_time_from_proper_timezone,
active: nil
}
end
end
class Degree < ApplicationRecord
has_many :degreeholderships
has_many :profiles, through: :degreeholderships, dependent: :destroy
end
我尝试使用和不使用recursive:true选项运行还原以及设置recovery_window值。全部显示此行为。我还删除了使用活动列的选项,并恢复使用deleted_at(默认值)。
我想知道这种行为是否是:
答案 0 :(得分:0)
参数:{“type”=&gt;“restore”,“id”=&gt;“18”}
Pt负载(0.6ms)SELECT“pts”。* FROM“pts”WHERE“pts”。“deleted_at”IS NULL AND“pts”。“id”= $ 1 LIMIT $ 2 [[“id”,18], [“LIMIT”,1]]
覆盖默认查询适用于除destroy,real destroy和restore
之外的所有方法在9ms内完成401未授权(ActiveRecord:1.3ms)
ActiveRecord :: RecordNotFound(找不到'id'= 18 [WHERE“pts”。“deleted_at”IS NULL]的产品):
这是一个没有关联的简单1表吗?