title: Rails 4 - Respond only to JSON and not HTML
body: <p>I'm trying to build an API in rails 4, and am having an issue where rails returns a 500 error instead of a 406 when using <code>respond_to :json</code> and trying to access the html version.</p>
  
  <p>Here's an example controller demonstrating the problem:</p>
  
  <pre><code>class PostsController &lt; ApplicationController
    respond_to :json
  
    def index
      @posts = Post.all
    end
  end
  </code></pre>
  
  <p>I also have a jbuilder view for <code>index</code> that works when accessing via JSON. If I try accessing the route without the JSON extension, It attempts to load the HTML template (which doesn't exist) and returns a 500 error, instead of just rendering JSON or returning a 406 error.</p>
  
  <p>What could be causing this? Cheers for any help.</p>