# N00b question: 'Having troubles with map.namespace :admin'

**URL:** <https://www.ruby-forum.com/t/n00b-question-having-troubles-with-map-namespace-admin/190454>\
**Category:** Rails\
**Created:** [June 20, 2010, 9:30pm UTC](https://www.ruby-forum.com/t/n00b-question-having-troubles-with-map-namespace-admin/190454 "2010-06-20T21:30:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4da419/32.png) [@sebastian](https://www.ruby-forum.com/u/sebastian)\
**Post date:** [June 20, 2010, 9:30pm UTC](https://www.ruby-forum.com/t/n00b-question-having-troubles-with-map-namespace-admin/190454/1 "2010-06-20T21:30:19Z")

</div>

Hi everyone!  
Im having troubles with my routes.rb, i set map.namespace :admin so i  
can enter to my scaffold ‘contacts’ via admin/contacts’, but the view  
its crashing showing this error:; _undefined method `contact\_path’ for  
#ActionView::Base:0xb6743be4_

The question is: ‘where is _contact\_path_ variable declared?’

---

<div class="post-metadata">

**Author:** ![sebastian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4da419/32.png) [@sebastian](https://www.ruby-forum.com/u/sebastian)\
**Post date:** [June 21, 2010, 8:09pm UTC](https://www.ruby-forum.com/t/n00b-question-having-troubles-with-map-namespace-admin/190454/2 "2010-06-21T20:09:29Z")

</div>

The problem is it isn’t declared, but somewhere something is trying to  
use it.

The scaffold can be nice as a quickstart, but as you’re trying to do  
something new you’re going to have to make changes to the views (and  
the controllers too if they use named routes instead of :action  
=\> :whatever redirects).

A few things to try while tracking it down:

Look at the dev log (or your script/server output) for more  
information on the error. It should mention view templates in there  
somewhere, and that’ll help you find the file & line number to blame.  
The stack trace should be in the browser error page as well if you are  
in development mode.

Project search for the text contact\_path and change it to  
admin\_contact\_path or whatever is appropriate

Look for any forms that are using @contact instead of [:admin,  
@contact]  
(the symbol tells it about the routing namespace).

HTH

Nick

---

<div class="post-metadata">

**Author:** ![sebastian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4da419/32.png) [@sebastian](https://www.ruby-forum.com/u/sebastian)\
**Post date:** [June 22, 2010, 10:32pm UTC](https://www.ruby-forum.com/t/n00b-question-having-troubles-with-map-namespace-admin/190454/3 "2010-06-22T22:32:32Z")

</div>

I’m going to start using Netbeans, I’m using vim right now for my new  
experience with ror. That can solve my undeclared variable problem.  
So I can say the main problem is trying to call a controller via  
‘admin/:controller’. I can see that map.resources it’s not the  
answer… Correct me if I am wrong.  
How can I solve it?

Thanks for the reply. It was very useful.

---

<div class="post-metadata">

**Author:** ![sebastian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/4da419/32.png) [@sebastian](https://www.ruby-forum.com/u/sebastian)\
**Post date:** [June 22, 2010, 10:37pm UTC](https://www.ruby-forum.com/t/n00b-question-having-troubles-with-map-namespace-admin/190454/4 "2010-06-22T22:37:14Z")

</div>

Sebastian wrote:

> Hi everyone!  
> Im having troubles with my routes.rb, i set map.namespace :admin so i  
> can enter to my scaffold ‘contacts’ via admin/contacts’, but the view  
> its crashing showing this error:; _undefined method `contact\_path’ for  
> #ActionView::Base:0xb6743be4_
> 
> The question is: ‘where is _contact\_path_ variable declared?’

If you’re having a routing issue, the first place to start is to verify  
that you have the routes you think you have…

rake routes \>routes.lst

then peruse your routes.lst file.

Sounds like you scaffolded your initial views, then changed the  
namespace, and broke the generated routing scaffolded into your views.
