我正在使用带有 rails_admin 0.8.1、mongoid 5.0 和mongoid_paranoia的 Rails 4.1.14 。我创建了RailsAdmin 自定义操作来恢复软删除的用户。
class Restore
...
register_instance_option :controller do
Proc.new do
object.restore
...
end
end
end
但我不断得到
User with id '5695997df5740c17b0000002' could not be found
来自我的开发日志
Started GET "/admin/user/5695997df5740c17b0000002/restore" for 127.0.0.1 at 2016-01-12 16:35:04 -0800
Processing by RailsAdmin::MainController#restore as HTML
Parameters: {"model_name"=>"user", "id"=>"5695997df5740c17b0000002"}
MONGODB | localhost:27017 | rails425_dev.find | STARTED | {"find"=>"users", "filter"=>{"deleted_at"=>nil, "_id"=>BSON::ObjectId('56956c76f5740c1d68000000')}, "limit"=>-1}
问题是每个 default_scope 查询过滤掉 deleted_at 不为零的记录。关于如何覆盖它的任何建议?