我正在使用Rails 4.1.14與rails_admin 0.8.1,mongoid 5.0和mongoid_paranoia。我創建了RailsAdmin custom action來恢復軟刪除的用戶。RailsAdmin自定義操作來恢復軟刪除記錄
class Restore
...
register_instance_option :controller do
Proc.new do
object.restore
...
end
end
end
但我不斷收到
User with id '5695997df5740c17b0000002' could not be found
從我develoment.log
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不爲零。有關如何覆蓋它的任何建議?
你是如何設法恢復帶有偏執狂的rails_admin中的記錄的?我添加了with_deleted和only_deleted範圍,我看到它們但無法恢復或永久銷燬它們。即使添加了自定義操作來恢復它,但它說沒有找到記錄。 – StarWars
要回答近2年前的@StarWars問題,請參閱Dave Burt的答案[這裏](https://stackoverflow.com/questions/20069425/how-do-i-show-unscoped-models-in-rails-admin) – Chiperific