title: ActionController::UnknownFormat in DocumentHistoriesController# with a format.js
body: <p>I am trying to call a partial on a form and have the partial update without refreshing the rest of the form. </p>
  
  <p>The partial is called in my complaints form</p>
  
  <pre><code> &lt;div id="refresh_assigned"&gt;
      &lt;%= render :partial =&gt; '/document_histories/history_for_complaint_form' %&gt;
   &lt;/div&gt;
  </code></pre>
  
  <p>I am calling a delete in \document_histories_history_for_complaint_form.html.erb</p>
  
  <pre><code>    &lt;td&gt;&lt;%= link_to 'Delete', history, method: :delete, data: { confirm: "Are you sure that you want to remove this users assignment to this complaint? \n \n The user will NOT be notified via email. "} %&gt;&lt;/td&gt;
  </code></pre>
  
  <p>My destroy def in the document_histories controller is </p>
  
  <pre><code> def destroy
      @document_history.destroy
      respond_to do |format|
  
        format.js {}
        format.json { render :show, status: :ok, location: @document_history }
  
      end
    end
  </code></pre>
  
  <p>I have a js file of \app\views\document_histories\destroy.js.erb</p>
  
  <pre><code>$('#refresh_assigned').html("&lt;%= escape_javascript(render(:partial =&gt; 'document_histories/history_for_complaint_form')).html_safe %&gt;");
  </code></pre>
  
  <p>The error I am getting is </p>
  
  <pre><code>ActionController::UnknownFormat in DocumentHistoriesController#destroy
  ActionController::UnknownFormat
  Rails.root: C:/Users/cmendla/RubymineProjects/internal_complaints
  Application Trace | Framework Trace | Full Trace
  app/controllers/document_histories_controller.rb:209:in `destroy'
  </code></pre>
  
  <p>Line 209 is respond_to do |format|</p>
  
  <hr>
  
  <p>Here is the log when I try to delete after making the change suggested by Pavan. It looks like I am getting a Nil class error when trying to refresh the div</p>
  
  <pre><code>Started DELETE "/document_histories/364" for ::1 at 2016-02-23 09:22:21 -0500
  Processing by DocumentHistoriesController#destroy as JS
    Parameters: {"id"=&gt;"364"}
    [1m[35mUser Load (1.0ms)[0m  SELECT  "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1  [["id", 1]]
    [1m[36mDocumentHistory Load (0.0ms)[0m  [1mSELECT  "document_histories".* FROM "document_histories" WHERE "document_histories"."id" = ? LIMIT 1[0m  [["id", 364]]
    [1m[35m (0.0ms)[0m  begin transaction
    [1m[36mSQL (9.0ms)[0m  [1mDELETE FROM "document_histories" WHERE "document_histories"."id" = ?[0m  [["id", 364]]
    [1m[35m (11.0ms)[0m  commit transaction
    Rendered document_histories/_history_for_complaint_form.html.erb (2.0ms)
    Rendered document_histories/destroy.js.erb (5.0ms)
  Completed 500 Internal Server Error in 42ms (ActiveRecord: 21.0ms)
  
  ActionView::Template::Error (undefined method `each' for nil:NilClass):
       8:       &lt;th&gt; Remarks&lt;/th&gt;
       9:     &lt;/tr&gt;
      10: 
      11:   &lt;% @document_histories.each do |history| %&gt;
      12: 
      13: 
      14: 
    app/views/document_histories/_history_for_complaint_form.html.erb:11:in `_app_views_document_histories__history_for_complaint_form_html_erb___652294712_44088072'
    app/views/document_histories/destroy.js.erb:1:in `_app_views_document_histories_destroy_js_erb___293771988_76518024'
  
  
    Rendered C:/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/templates/rescues/_trace.text.erb (1.0ms)
    Rendered C:/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/templates/rescues/_request_and_response.text.erb (1.0ms)
    Rendered C:/Ruby200/lib/ruby/gems/2.0.0/gems/actionpack-4.2.5/lib/action_dispatch/middleware/templates/rescues/template_error.text.erb (19.0ms)
  </code></pre>