ruby-on-rails - Searchkick::ImportError in Devise::SessionsController#destroy
问题描述
我正在尝试将 API 添加到现有的 Rails 应用程序,并发现自己在尝试从应用程序注销时遇到了以前从未遇到过的错误。
错误如下:
Searchkick::ImportError in Devise::SessionsController#destroy
{"type"=>"cluster_block_exception", "reason"=>"blocked by: [FORBIDDEN/12/index read-only / allow delete (api)];"} on item with id '1299d9c9-e5c9-4e49-b0ff-b986c415eee8'
自从我开始玩添加 API 以来,这种情况一直在发生。我添加了以下控制器:
module Api
module V1
class ApiController < ActionController::Base
#before_action :check_basic_auth
#skip_before_action :verify_authenticity_token
private
def check_basic_auth
unless request.authorization.present?
head :unauthorized
return
end
authenticate_with_http_basic do |email, password|
user = User.find_by(email: email.downcase)
if user && user.authenticate(password)
@current_user = user
else
head :unauthorized
end
end
end
def current_user
@current_user
end
end
end
end
和一个特定的控制器:
module Api
模块 V1 类 MicropostsController < ApiController def index @microposts = Event.all.paginate(page: params[:page]) 渲染 json: @microposts
end
def show
@micropost = Event.where(id: params[:id])
respond_to do |format|
format.html
format.js
format.xml {render xml: @micropost}
format.json {render json: @micropost}
end
end
end
结束结束
请问有什么明显的原因可以与设计交互吗?
解决方案
在进行更多搜索后,我找到了有效的解决方案:
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
推荐阅读
- python - 为什么在使用 unittest 修补类时会出现断言错误?
- react-native - React Native Expo 音频 | 从最新位置播放直播
- jsf - 当组件在 JSTL forEach 循环中时,以编程方式使用值表达式设置属性
- oracle - 如何按ID删除自上一行以来没有变化的旧行
- python - 在 python 中从 REST API 获取数据的最快方法
- java - 急切地加载一个标记为懒惰的集合?
- javascript - 在下面的示例中,递归是如何工作的?
- redux - 在自定义钩子中访问 Redux 状态?
- python - 应用于 Pandas 系列的 Json_normalize 在“str”和“int”实例之间返回“>”不支持
- spring-boot - 使用 DataSource 时获得过多的角色连接