# Module loading

**URL:** <https://www.ruby-forum.com/t/module-loading/78326>\
**Category:** Rails\
**Created:** [December 28, 2005, 1:00am UTC](https://www.ruby-forum.com/t/module-loading/78326 "2005-12-28T01:00:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sprsquish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sprsquish](https://www.ruby-forum.com/u/sprsquish)\
**Post date:** [December 28, 2005, 1:00am UTC](https://www.ruby-forum.com/t/module-loading/78326/1 "2005-12-28T01:00:57Z")

</div>

I’ve looked high and low for the answer to this and can’t seem to find  
anything that helps.

I have an admin section (much like Typo) where all controllers are based  
on the Admin::BaseController.

My directory structure is  
[RAILS]  
-app  
–controllers  
—admin  
----base\_controller.rb  
----products\_controller.rb

Products controller is:  
class Admin::ProductsController \< Admin::BaseController  
end

base\_controller.rb is:  
class Admin::BaseController  
end

However I keep getting this error:  
NameError: Cannot load module Admin: Object::Admin is set to Admin

Can anyone help me out with this, please?

---

<div class="post-metadata">

**Author:** ![sprsquish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sprsquish](https://www.ruby-forum.com/u/sprsquish)\
**Post date:** [December 28, 2005, 3:22pm UTC](https://www.ruby-forum.com/t/module-loading/78326/2 "2005-12-28T15:22:37Z")

</div>

Shouldn’t the BaseController be defined something like:

class Admin::BaseController \< ActionController::Base  
end

(\< ActionController::Base being the key part there)

-Nick

---

<div class="post-metadata">

**Author:** ![sprsquish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sprsquish](https://www.ruby-forum.com/u/sprsquish)\
**Post date:** [December 28, 2005, 8:52pm UTC](https://www.ruby-forum.com/t/module-loading/78326/3 "2005-12-28T20:52:14Z")

</div>

My apologies. BaseController is defined

class Admin::BaseController \< ApplicationController  
end

ApplicationController is as it always is:

class ApplicationController \< ActionController::Base  
end

Nick S. wrote:

> Shouldn’t the BaseController be defined something like:
> 
> class Admin::BaseController \< ActionController::Base  
> end
> 
> (\< ActionController::Base being the key part there)
> 
> -Nick

---

<div class="post-metadata">

**Author:** ![sprsquish](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/d9b06d/32.png) [@sprsquish](https://www.ruby-forum.com/u/sprsquish)\
**Post date:** [December 28, 2005, 9:02pm UTC](https://www.ruby-forum.com/t/module-loading/78326/4 "2005-12-28T21:02:06Z")

</div>

Ok just checking…been there done that one on my own 🙂

Unfortunatly I’m not sure what the problem is then. I have an app with  
this same type of setup with a bunch of controllers under the admin  
module/directory.

Guessing you generated them by: `ruby script/generate controller "admin/some_controller"`?

What happens when you do the above with a default index action and you  
try to view it (dont change it at all)? Same error?

-Nick
