1

我正在开发一个 Rails 6 应用程序,active-admin我想在其中显示所有记录,包括用paranoia.

我做了那个添加scope :with_deleted, default: true

ActiveAdmin.register Post do
  actions :all, except: [:edit, :new]
  permit_params :body, :user_id

  scope :with_deleted, default: true
end

但是当我点击仪表板中的view操作时,active-admin软删除的记录我得到一个

ActiveRecord::RecordNotFound in Admin::PostController#show
Couldn't find Post with 'id'=2 [WHERE "post"."deleted_at" IS NULL]

如何更改活动管理员中的搜索?

更新:我解决了这个添加这个代码/admin/posts.rb

  controller do
    def show
      @post = Post.find_by_id(params[:id])
    end

    def scoped_collection
      Post.with_deleted
    end
  end
4

0 回答 0