title: Rails ActionController::UnknownFormat error with respond_to
body: <p>i'm getting this error, when trying to use ajax.  I did some searching, but couldn't solve my problem</p>
  
  <p><code>ActionController::UnknownFormat</code></p>
  
  <p>Drafts Controller:</p>
  
  <pre><code>  def index
      if params["format"] != nil
        @draft = Draft.find_by(id: params["format"].to_i)
        respond_to do |format|
          format.js
        end
      end
      @draft = current_user.drafts.build
      @drafts = current_user.drafts.non_submitted
      @being_edited_drafts = current_user.drafts.being_edited
      @completed_drafts = current_user.drafts.completed
    end
  </code></pre>
  
  <p>index.js.erb</p>
  
  <pre><code>$('.draft_&lt;%= @draft.id %&gt;').trigger('click');
  </code></pre>
  
  <p>log:</p>
  
  <pre><code>Started GET "/drafts.132" for 127.0.0.1 at 2014-11-26 11:56:28 -0800
  Processing by DraftsController#index as 
    User Load (0.5ms)  SELECT  "users".* FROM "users"  WHERE "users"."id" = 4  ORDER BY     "users"."id" ASC LIMIT 1
    Draft Load (0.4ms)  SELECT  "drafts".* FROM "drafts"  WHERE "drafts"."id" = 132 LIMIT 1
  Completed 406 Not Acceptable in 5ms
  
  ActionController::UnknownFormat - ActionController::UnknownFormat:
  actionpack (4.1.7) lib/action_controller/metal/mime_responds.rb:440:in   `retrieve_collector_from_mimes'
  actionpack (4.1.7) lib/action_controller/metal/mime_responds.rb:256:in `respond_to'
  app/controllers/drafts_controller.rb:16:in `index'
  actionpack (4.1.7) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
  actionpack (4.1.7) lib/abstract_controller/base.rb:189:in `process_action'
  actionpack (4.1.7) lib/action_controller/metal/rendering.rb:10:in `process_action'
  actionpack (4.1.7) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
  activesupport (4.1.7) lib/active_support/callbacks.rb:113:in `call'
  activesupport (4.1.7) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.7) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.7) lib/active_support/callbacks.rb:229:in `block in halting'
  activesupport (4.1.7) lib/active_support/callbacks.rb:215:in `block in halting_and_conditional'
  activesupport (4.1.7) lib/active_support/callbacks.rb:166:in `block in halting'
  activesupport (4.1.7) lib/active_support/callbacks.rb:166:in `block in halting'
  </code></pre>
  
  <p>Create Method.  This loads the index with params["format"]</p>
  
  <pre><code>def create
    @draft = Draft.create(draft_params)
    if @draft.save
      redirect_to drafts_path(@draft.id),notice: "Draft was successfully saved"
    else
      render action: 'new'
    end
  end
  </code></pre>
  
  <p>Form where create method is called</p>
  
  <pre><code>= form_for @draft, :html =&gt; { :multipart =&gt; true } do |f|
    = f.hidden_field :user_id, value: current_user.id
    #new-post-title
      = f.text_field :title, :value =&gt; "&lt;h1&gt;&lt;b&gt;Title&lt;/b&gt;&lt;/h2&gt;"
  
    #new-post-body
     = f.text_area :body, :value =&gt; "&lt;p&gt;Start writing&lt;/p&gt;"
  
    .text-center
     = f.submit "New Draft", :class =&gt; "btn btn-sm btn-primary btn-round"
  </code></pre>