简体   繁体   English

Activeadmin破坏记录,并在管理中出现Elasticsearch :: Transport :: Transport :: Errors :: NotFound异常[404]

[英]Activeadmin Destroy Record with Exception Elasticsearch::Transport::Transport::Errors::NotFound in Admin [404]

I've configured Elasticsearch in my Rails application API and for Post model, it's working properly and I'm using @post.destroy! 我已经在Rails应用程序API中配置了Elasticsearch,对于Post模型,它可以正常工作,并且我正在使用@post.destroy! to delete a specific record without any problem, but when I'm trying the same through Activeadmin panel destroy action (I tried default destroy action and custom controller -> destroy action ), here what's happening is deleting the record properly from db but after deleting it throws an exception : 删除特定记录没有任何问题,但是当我通过Activeadmin面板中的destroy动作(我尝试使用默认的destroy动作和自定义控制器-> destroy action)尝试相同操作时, 这里发生的是从db中正确删除记录,但是删除后它抛出一个异常

Elasticsearch::Transport::Transport::Errors::NotFound in Admin::PostsController#destroy

[404] {"found":false,"_index":"posts","_type":"post","_id":"1802","_version":1,"_shards":{"total":2,"successful":1,"failed":0}}

I've tried all custom callbacks which mentioned in elasticsearch-model documentation but the only one solution I found is by using begin .. rescue statement: 我已经尝试了Elasticsearch-model文档中提到的所有自定义回调,但是我发现的唯一解决方案是使用begin .. rescue语句:

@deleted = false
begin
  @post.destroy!
rescue
  Post.find_by(:id => id).present? ? @deleted = false : @deleted = true
  #delete successful action here if @deleted == true
end

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Elasticsearch :: Transport :: Transport :: Errors :: NotFound:[404] - Elasticsearch::Transport::Transport::Errors::NotFound: [404] Elasticsearch :: Transport :: Transport :: Errors :: NotFound([404] {“错误”:{“ root_cause”:[{“类型”:“ index_not_found_exception” - Elasticsearch::Transport::Transport::Errors::NotFound ([404] {“error”:{“root_cause”:[{“type”:“index_not_found_exception” 使用ActiveAdmin,SearchKick和SearchBox在Heroku上出现Elasticsearch :: Transport :: Transport :: Errors - Elasticsearch::Transport::Transport::Errors on Heroku with ActiveAdmin, SearchKick and SearchBox Elasticsearch ::运输::运输::错误:: BadRequest错误heroku - Elasticsearch::Transport::Transport::Errors::BadRequest error heroku 搜索#search中的Rails:Elasticsearch :: Transport :: Transport :: Errors :: BadRequest - Rails: Elasticsearch::Transport::Transport::Errors::BadRequest in Search#search Elasticsearch::Transport::Transport::Errors::BadRequest [400] 创建索引时 - Elasticsearch::Transport::Transport::Errors::BadRequest [400] while creating index Elasticsearch::Transport::Transport::Errors::Forbidden: [403] 发送超过 1200 个字符的文本字段时出错 - Elasticsearch::Transport::Transport::Errors::Forbidden: [403] error when sending text fields with more than 1200 characters Elasticsearch :: Transport :: Transport :: Errors :: NotAcceptable:[406] {“错误”:“不支持Content-Type标头[]”,“状态”:406} - Elasticsearch::Transport::Transport::Errors::NotAcceptable: [406] {“error”:“Content-Type header [] is not supported”,“status”:406} activeadmin with rails API app errors:Admin :: DashboardController #index中的ArgumentError - activeadmin with rails API app errors: ArgumentError in Admin::DashboardController#index 使用CanCan时如何启用管理员销毁记录? - How can I enable admin to destroy the record when using CanCan?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM