# Namespaced Controller and Model Access

**URL:** <https://www.ruby-forum.com/t/namespaced-controller-and-model-access/180984>\
**Category:** Rails\
**Created:** [January 3, 2010, 12:14am UTC](https://www.ruby-forum.com/t/namespaced-controller-and-model-access/180984 "2010-01-03T00:14:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nicholas\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/779978/32.png) [@Nicholas\_Y](https://www.ruby-forum.com/u/Nicholas_Y)\
**Post date:** [January 3, 2010, 12:14am UTC](https://www.ruby-forum.com/t/namespaced-controller-and-model-access/180984/1 "2010-01-03T00:14:51Z")

</div>

Hi everyone,

I’m building a CMS-y app, and wanted to namespace my admin  
controllers, ex. “admin/pages/new”. However, it appears that I can’t  
get to my models, which are just in the general /app/models directory.  
Whenever I try to call a model, I get an Uninitialized Constant  
error… I’ve seen Radiant CMS do this, apparently without any  
issues… Ideas?

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).

---

<div class="post-metadata">

**Author:** ![Nicholas\_Y](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/779978/32.png) [@Nicholas\_Y](https://www.ruby-forum.com/u/Nicholas_Y)\
**Post date:** [January 3, 2010, 1:19pm UTC](https://www.ruby-forum.com/t/namespaced-controller-and-model-access/180984/2 "2010-01-03T13:19:45Z")

</div>

Alright, so I fixed my problem, and wanted to post it here for anyone  
else that might be having the same issue. Basically, I just prefixed  
my model classes with two colons, like so:

@node = ::Node.new

This forces the namespaced controller to look for the model in the  
standard model directory.

On Jan 2, 8:14 am, Nicholas Y. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi everyone,
> 
> I’m building a CMS-y app, and wanted to namespace my admin  
> controllers, ex. “admin/pages/new”. However, it appears that I can’t  
> get to my models, which are just in the general /app/models directory.  
> Whenever I try to call a model, I get an Uninitialized Constant  
> error… I’ve seen Radiant CMS do this, apparently without any  
> issues… Ideas?

–

You received this message because you are subscribed to the Google  
Groups “Ruby on Rails: Talk” group.  
To post to this group, send email to removed\_email\_address@domain.invalid.  
To unsubscribe from this group, send email to  
removed\_email\_address@domain.invalid.  
For more options, visit this group at  
[http://groups.google.com/group/rubyonrails-talk?hl=en](http://groups.google.com/group/rubyonrails-talk?hl=en).
