title: Rails respond_to issue with json
body: <p>I'm doing some HTML5 uploading and encountering a problem I can't seem to figure out. Take this functioning code:</p>
  
  <pre><code>if @image.save
      render :json =&gt; {:status =&gt; "Successfully uploaded image!"}
  else
      render :json =&gt; {:status =&gt; "Something went wrong with your upload!"}
  end
  </code></pre>
  
  <p>That works and it does exactly what it's supposed to. However, when I add respond_to to catch HTML requests, it fails completely (though the HTML portion works.)</p>
  
  <pre><code>respond_to do |format|
      if @image.save
          format.html {redirect_to(edit_product_path(@image.product), :notice =&gt; "Your image was added successfully.")}
          format.json {render :status =&gt; "Successfully uploaded image!"}
      else
          format.html {redirect_to(edit_product_path(@image.product), :alert =&gt; "An error occurred while attempting to upload your image. Please try again.")}
          format.json {render :status =&gt; "Something went wrong with your upload!"}
      end 
  end
  </code></pre>
  
  <p>Any ideas what could be wrong? I feel like I'm overlooking something simple. Thanks.</p>
  
  <p><strong>EDIT - ISSUE RESOLVED</strong></p>
  
  <p>I figured it was a stupid thing I kept overlooking. Turns out the request was HTML, not JSON, which was due to the fact that since uploading required the content type to be multipart/form-data the respond_to was triggering HTML.</p>