Unable to autoload constant API Controller in Rails 4
<p>I'm creating a simple api endpoint in my Rails 4.2.6 app but am having problems with it.</p>

<p>When I hit the url: <a href="http://lvh.me:9077/api/v1/grubs" rel="noreferrer">http://lvh.me:9077/api/v1/grubs</a> I receive the following error:</p>

<pre><code>Unable to autoload constant Api::V1::GrubsController, expected /Users/shakycode/code/grubs/app/controllers/api/v1/grubs_controller.rb to define it
</code></pre>

<p>Here is my routes.rb file defining the endpoint.</p>

<pre><code>namespace :api do
    namespace :v1 do
      resources :grubs, only: [:index]
    end
  end
</code></pre>

<p>Here is my app/controllers/api/v1/grubs_controller.rb</p>

<pre><code>class API::V1::GrubsController &lt; ApplicationController
   protect_from_forgery with: :null_session
   before_action :destroy_session

 def destroy_session
   request.session_options[:skip] = true
 end

  def index
    @grubs = Grub.all
    respond_to do |format|
      format.json { render json: @grubs}
    end
  end
end
</code></pre>

<p>I have a Rails 4.2.1 app where I used the same strategy, but in 4.2.6 I'm having this error occur when I try to pull against the API.</p>

<p>Thanks in advance!</p>

<p>Update: Here's the exception that is raised using better_errors in the browser:</p>

<pre><code>load_missing_constantactivesupport (4.2.6) lib/active_support/dependencies.rb
490
491
492
493
494
495
496
497
498
499
500
        if loading.include?(expanded)
          raise "Circular dependency detected while autoloading constant #{qualified_name}"
        else
          require_or_load(expanded, qualified_name)
          raise LoadError, "Unable to autoload constant #{qualified_name}, expected #{file_path} to define it" unless from_mod.const_defined?(const_name, false)
          return from_mod.const_get(const_name)
        end
      elsif mod = autoload_module!(from_mod, const_name, qualified_name, path_suffix)
        return mod
      elsif (parent = from_mod.parent) &amp;&amp; parent != from_mod &amp;&amp;
</code></pre>