首页 > 解决方案 > 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

结束结束

请问有什么明显的原因可以与设计交互吗?

标签: ruby-on-rails

解决方案


在进行更多搜索后,我找到了有效的解决方案:

curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'

推荐阅读