ActionView::MissingTemplate, Rails 5 API with JSON
<p>I am consistently getting an ActionView::MissingTemplate error when trying to render JSON in my Rails 5 Api. I just want to render the pure JSON, without a jbuilder or other view. Can anyone help?</p>

<p>thing_controller.rb:</p>

<pre class="lang-rb prettyprint-override"><code>class Api::ThingController &lt; ApplicationController
  def thing
    render json: {error: 'This is my error message.'}, status: 422
  end
end
</code></pre>

<p>thing_controller_test.rb:</p>

<pre class="lang-rb prettyprint-override"><code>require 'test_helper'
class Api::ThingControllerTest &lt; ActionDispatch::IntegrationTest
  test "the truth" do
    get '/api/thing'
    assert_response 422
  end
end
</code></pre>

<p>full error message:</p>

<blockquote>
  <p>Error: Api::ThingControllerTest#test_the_truth:
  ActionView::MissingTemplate: Missing template api/thing/thing,
  application/thing with {:locale=>[:en], :formats=>[:json],
  :variants=>[], :handlers=>[:raw, :erb, :html, :builder, :ruby,
  :jbuilder]}. </p>
</blockquote>

<p>application_controller.rb:
</p>

<pre><code> class ApplicationController &lt; ActionController::API
    include ActionController::Caching
    include ActionController::ImplicitRender  # want implicit view rendering for JBuilder

  before_action :add_cors_headers


  def options
    head(:ok) if request.request_method == "OPTIONS"
  end
</code></pre>