title: Elasticsearch::Transport::Transport::Errors on Heroku with ActiveAdmin, SearchKick and SearchBox
body: <p>I have a Rails App with a Post Model and Controller and I'm using ActiveAdmin for CMS. I have implemented ElasticSearch and SearchKick and am now attempting to deploy to Heroku using SearchBox.
  The app runs on local no issues and the majority of the functionality works on Heroku but I am getting a very annoying error when I Update or Create Post in Active Admin. </p>
  
  <blockquote>
    <p>Elasticsearch::Transport::Transport::Errors::NotFound in
    Admin::PostsController#update [404]
    {"error":{"root_cause":[{"type":"document_missing_exception","reason":"[post][11]:
    document
    missing","index":"posts","shard":"0"}],"type":"document_missing_exception","reason":"[post][11]:
    document missing","index":"posts","shard":"0"},"status":404}</p>
  </blockquote>
  
  <p>Even though it is throwing this error the Post is still either Updating or Creating fine. If I refresh the page it resolves to the view all posts screen in ActiveAdmin as expected. The search functionality is fully operational on the front end.</p>
  
  <p>In SearchBox the ElasticSearch index is named posts_production_20160220081603930. Can't work out how to make ActiveAdmin see it. The Post Model sees it and I am able to search as expected.</p>
  
  <p>Post Controller...</p>
  
  <pre><code>class PostsController &lt; ApplicationController
    before_filter :find_post, :only =&gt; [:show, :edit, :update, :destroy]
  
    def index
      @post = Post.all
      if params[:q].present?
        @postsearch = Post.search params[:q], fields: [:title, :body], operator: "or", suggest: true
      end
    end
  
    def show
      if params[:q].present?
        @postsearch = Post.search params[:q], fields: [:title, :body], operator: "or", suggest: true
      else
        @post = Post.find(params[:id])
        respond_to do |format|
          format.html # show.html.erb
          format.xml  { render :xml =&gt; @post }
        end
      end
    end
  
    def create
      @post = Post.new(params[:post])
      respond_to do |format|
        if @post.save
          format.html  { redirect_to(@post, :notice =&gt; 'Post was successfully created.') }
          format.json  { render :json =&gt; @post, :status =&gt; :created, :location =&gt; @post }
        else
          format.html  { render :action =&gt; "new" }
          format.json  { render :json =&gt; @post.errors, :status =&gt; :unprocessable_entity }
        end
      end
    end
  
    def new
      @post = Post.new
      respond_to do |format|
        format.html # new.html.erb
        format.xml  { render :xml =&gt; @post }
      end
    end
  
    def edit
      @post = Post.find(params[:id])
    end
  
    def update
      @post = Post.find(params[:id])
      respond_to do |format|
        if @post.update_attributes(params[:post])
          flash[:notice] = 'Post was successfully updated.'
          format.html { redirect_to(@post) }
          format.xml  { head :ok }
        else
          format.html { render :action =&gt; "edit" }
          format.xml  { render :xml =&gt; @post.errors,
                      :status =&gt; :unprocessable_entity }
        end
      end
    end
  
    def destroy
      @post = Post.find(params[:id])
      @post.destroy
      respond_to do |format|
        format.html { redirect_to(posts_url) }
        format.xml  { head :ok }
      end
    end
  
    private
  
    def find_post
      @post = Post.find(params[:id])
    end
  end
  </code></pre>
  
  <p>Post Model</p>
  
  <pre><code>require 'elasticsearch/model'
  class Post &lt; ActiveRecord::Base
    searchkick suggest: [:title]
    #add attachement declaration to moidels for refile image uploading
    include Elasticsearch::Model
    include Elasticsearch::Model::Callbacks
    validates_presence_of :title, :body
    attachment :profile_image
    attachment :image
  end
  </code></pre>
  
  <p>ActiveAdmin Post</p>
  
  <pre><code>ActiveAdmin.register Post do
    # See permitted parameters documentation:
    # https://github.com/activeadmin/activeadmin/blob/master/docs/2-resource-customization.md#setting-up-strong-parameters
    permit_params :title, :body, :profile_image, :image
  
    form do |f|
      inputs 'Details' do
        input :title
        input :body, :input_html =&gt; {:class =&gt; "redactor"}
        input :profile_image, :required =&gt; false, :as =&gt; :file, destroy: false, :direct =&gt; true
        input :image, :required =&gt; false, :as =&gt; :file, destroy: false, :direct =&gt; true
        actions
      end
    end
  end
  </code></pre>
  
  <p>To create the original index I ran </p>
  
  <blockquote>
    <p>heroku run rake searchkick:reindex CLASS=Post</p>
  </blockquote>
  
  <p>In dev the index gets updated automatically but in prod I have to reindex manually. Haven't setup sidekiq yet.</p>
  
  <p>Any help would be greatly appreciated.</p>
  
  <p>Am going a bit mad.</p>
  
  <p>Cheers</p>
  
  <p>Dan</p>