title: Why does mounting a route in Rails fail with "uninitialized constant API"?
body: <p>I am working on an app that includes an <code>API</code> that is using the <code>grape</code> gem.</p>
  
  <p>Here is my <code>Root</code> Class:</p>
  
  <pre><code>module API
    class Root &lt; Grape::API
      rescue_from :all do |e|
        Rack::Response.new(
          [ "Error: #{e.message}" ],
          500,
          { "Content-type" =&gt; "text/error" }
        ).finish
      end
  
      prefix "api"
      version 'v1', using: :path
      format :json
      error_format :json
  
      mount ::API::ServiceRequests
    end
  end
  </code></pre>
  
  <p>Here is how I am mounting it in routes:</p>
  
  <p><code>mount API::Root =&gt; '/'</code></p>
  
  <p>The error I am receiving is:
  <code>routes.rb:45:in</code>block in ': uninitialized constant API (NameError)`</p>
  
  <p>The files are structured like <code>app/api/root.rb</code> and I have this bit of code in my <code>application.rb</code> to load in the files:</p>
  
  <pre><code>config.paths.add File.join('app', 'api'), glob: File.join('**', '*.rb')
  config.autoload_paths += Dir[Rails.root.join('app', 'api', '*')]
  </code></pre>