Namespaced Controller and Model Access

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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.

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. [email protected] 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.