title: uninitialized constant (NameError) with custom Devise class with namespaces
body: <p>I followed some tutorials to create an API for my app. I put the custom controller which inherits from Devise registration and session controllers. I've looked through tons of questions/answers here and cannot resolve my problem.</p>
  
  <p>My solution works on my Ubuntu VM but not on an ec2 instance. Here's the first line of the new class:</p>
  
  <pre><code>class Api::V1::SessionsController &lt; Devise::SessionsController
  </code></pre>
  
  <p>and some code from routes.rb:</p>
  
  <pre><code>devise_for :users
  
  namespace :api do
  namespace :v1 do
   devise_scope :user do
     post 'registrations' =&gt; 'registrations#create', :as =&gt; 'register'
     post 'sessions' =&gt; 'sessions#create', :as =&gt; 'login'
     delete 'sessions' =&gt; 'sessions#destroy', :as =&gt; 'logout'
   end
   get 'tournaments' =&gt; 'tournaments#index', :as =&gt; 'tournaments'
  end
  end
  </code></pre>
  
  <p>My custom controller is in the Api/V1 directory and appears routed correctly. The error is (with a portion of the trace):</p>
  
  <pre><code>        
  ActionController::RoutingError (uninitialized constant Api):
    activesupport (3.2.13) lib/active_support/inflector/methods.rb:230:in `block in constantize'
    activesupport (3.2.13) lib/active_support/inflector/methods.rb:229:in `each'
    activesupport (3.2.13) lib/active_support/inflector/methods.rb:229:in `constantize'
    actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:69:in `controller_reference'
    actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:54:in `controller'
    actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:32:in `call'
    actionpack (3.2.13) lib/action_dispatch/routing/mapper.rb:42:in `call'
    journey (1.0.4) lib/journey/router.rb:68:in `block in call'
    journey (1.0.4) lib/journey/router.rb:56:in `each'
    journey (1.0.4) lib/journey/router.rb:56:in `call'
    actionpack (3.2.13) lib/action_dispatch/routing/route_set.rb:612:in `call'
    rack-pjax (0.7.0) lib/rack/pjax.rb:12:in `call'
    mongoid (3.1.4) lib/rack/mongoid/middleware/identity_map.rb:34:in `block in call'
    mongoid (3.1.4) lib/mongoid/unit_of_work.rb:39:in `unit_of_work'
    mongoid (3.1.4) lib/rack/mongoid/middleware/identity_map.rb:34:in `call'
    warden (1.2.3) lib/warden/manager.rb:35:in `block in call'
    warden (1.2.3) lib/warden/manager.rb:34:in `catch'
    warden (1.2.3) lib/warden/manager.rb:34:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
    rack (1.4.5) lib/rack/etag.rb:23:in `call'
    rack (1.4.5) lib/rack/conditionalget.rb:35:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/head.rb:14:in `call'
    remotipart (1.2.1) lib/remotipart/middleware.rb:27:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
    actionpack (3.2.13) lib/action_dispatch/middleware/flash.rb:242:in `call'
  </code></pre>
  
  <p>And to get the server running, I had to set these flags in the applications.rb:</p>
  
  <pre><code># Code is not reloaded between requests
  config.cache_classes = false
  
  # Full error reports are disabled and caching is turned on
  config.consider_all_requests_local       = true
  config.action_controller.perform_caching = false
  </code></pre>