title: Rails superclass mismatch error with two controllers
body: <p>I have two controllers</p>
  
  <p>one is defined as</p>
  
  <pre><code>class Admin::Businesses::DealsController &lt; AdminController
  </code></pre>
  
  <p>it is located at <code>app/controllers/admin/businesses/deals_controller.rb</code></p>
  
  <p>the other</p>
  
  <pre><code>class Admin::DealsController &lt; AdminController
  </code></pre>
  
  <p>is located at <code>app/controllers/admin/deals_controller.rb</code></p>
  
  <p>Everything works find in development env but When I push to heroku and the app loads in production env it gives me this error </p>
  
  <pre><code> /app/app/controllers/businesses/deals_controller.rb:1:in `&lt;top (required)&gt;': superclass mismatch for class DealsController (TypeError)
  </code></pre>
  
  <p>related lines from my routes.rb look like this</p>
  
  <pre><code>namespace 'admin' do
      resources :deals do
      end
      resources :businesses do
        resources :deals, module: "businesses"
      end
   end
  </code></pre>
  
  <p>Why is it giving me this error, due to same name of controllers ? or super class mismatch ? How can I fix this. I want two controllers for deals one under admin and the other under admin/businesses for business specific actions.</p>
  
  <p>Here is the full stack trace when trying to run the app locally in prod env using
  rails s -e production</p>
  
  <pre><code>/home/abid/Projects/vocallocal/app/controllers/admin/businesses/deals_controller.rb:1: warning: toplevel constant Businesses referenced by Admin::Businesses
  Exiting
  /home/abid/Projects/vocallocal/app/controllers/businesses/deals_controller.rb:1:in `&lt;top (required)&gt;': superclass mismatch for class DealsController (TypeError)
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:359:in `require_or_load'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:313:in `depend_on'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:225:in `require_dependency'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:438:in `each'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:438:in `block in eager_load!'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:436:in `each'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/engine.rb:436:in `eager_load!'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/application/finisher.rb:53:in `block in &lt;module:Finisher&gt;'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `instance_exec'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:30:in `run'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:55:in `block in run_initializers'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `each'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/initializable.rb:54:in `run_initializers'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/application.rb:136:in `initialize!'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/railtie/configurable.rb:30:in `method_missing'
      from /home/abid/Projects/vocallocal/config/environment.rb:5:in `&lt;top (required)&gt;'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `block in require'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:236:in `load_dependency'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/activesupport-3.2.3/lib/active_support/dependencies.rb:251:in `require'
      from /home/abid/Projects/vocallocal/config.ru:4:in `block in &lt;main&gt;'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'
      from /home/abid/Projects/vocallocal/config.ru:1:in `new'
      from /home/abid/Projects/vocallocal/config.ru:1:in `&lt;main&gt;'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:200:in `app'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands/server.rb:46:in `app'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:252:in `start'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands/server.rb:70:in `start'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:55:in `block in &lt;top (required)&gt;'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:50:in `tap'
      from /usr/local/ruby/lib/ruby/gems/1.9.1/gems/railties-3.2.3/lib/rails/commands.rb:50:in `&lt;top (required)&gt;'
      from script/rails:6:in `require'
      from script/rails:6:in `&lt;main&gt;'
  </code></pre>
  
  <p>Thanks</p>