# POSTing in :admin namespace

**URL:** <https://www.ruby-forum.com/t/posting-in-admin-namespace/139863>\
**Category:** Rails\
**Created:** [June 8, 2008, 12:34pm UTC](https://www.ruby-forum.com/t/posting-in-admin-namespace/139863 "2008-06-08T12:34:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![goleksiak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecd19e/32.png) [@goleksiak](https://www.ruby-forum.com/u/goleksiak)\
**Post date:** [June 8, 2008, 12:34pm UTC](https://www.ruby-forum.com/t/posting-in-admin-namespace/139863/1 "2008-06-08T12:34:59Z")

</div>

I have a RESTful :admin namespace which works fine except for UPDATE  
and CREATE actions for the controllers in the :admin space. I am sure  
it is a namespace/routing issue and have looked through a bunch of  
posts but cannot find my error. In my Edit action I am getting:

The error occurred while evaluating nil.to\_sym

in my Edit view for the line:

\<% form\_for(@user) do |f| %\>

when I change this line to:

\<% form\_for([:admin, @user]) do |f| %\>

I get:

undefined method `admin\_admin\_users\_path’ for #\<ActionView::Base:  
0x6c1838\>

if I use:

\<% form\_for :user, @user do |f| %\>  
or  
\<% form\_for :user, @user, :url =\> admin\_user\_path(@user.id) do |f| %\>

I get:

Unknown action  
No action responded to 3

…what is wrong?!

My routes.rb:

\<  
map.resources :posts  
map.resources :consignments

map.namespace :admin do |admin|  
admin.resources :posts  
admin.resources :consignments  
admin.resources :users  
end

map.connect ‘:controller/:action/:id’  
map.connect ‘:controller/:action/:id.:format’

> 

My Admin::UsersController edit action:

\<  
def edit  
@user = Admin::Users.find(params[:id])  
@page\_title = @user.full\_name  
render :layout =\> ‘admin/default’  
end

> 

Thanks,  
Greg Oleksiak

---

<div class="post-metadata">

**Author:** ![goleksiak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecd19e/32.png) [@goleksiak](https://www.ruby-forum.com/u/goleksiak)\
**Post date:** [June 8, 2008, 4:29pm UTC](https://www.ruby-forum.com/t/posting-in-admin-namespace/139863/2 "2008-06-08T16:29:43Z")

</div>

Maybe a little quick tutorial on Admin Namespaces would be helpful.  
I’m in the planning stages of an application right now and would  
really like to add in an administration panel. Explain to me how to  
do this the best way from ground up. Maybe this will help our  
original poster.

On Jun 8, 8:31 am, “Ryan B. (Radar)” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![goleksiak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecd19e/32.png) [@goleksiak](https://www.ruby-forum.com/u/goleksiak)\
**Post date:** [June 8, 2008, 2:32pm UTC](https://www.ruby-forum.com/t/posting-in-admin-namespace/139863/3 "2008-06-08T14:32:50Z")

</div>

Why is your model called Users and not User? Also, what is the purpose  
of  
namespacing this model? Models need not be namespaced, because there  
should  
be no difference between the namespaces.

On Sun, Jun 8, 2008 at 10:15 AM, goleksiak [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> \<% form\_for(@user) do |f| %\>  
> if I use:  
> …what is wrong?!  
> admin.resources :consignments  
> def edit

–  
Appreciated my help?  
Recommend me on Working With Rails  
[http://workingwithrails.com/person/11030-ryan-bigg](http://workingwithrails.com/person/11030-ryan-bigg)

---

<div class="post-metadata">

**Author:** ![goleksiak](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/ecd19e/32.png) [@goleksiak](https://www.ruby-forum.com/u/goleksiak)\
**Post date:** [June 8, 2008, 7:47pm UTC](https://www.ruby-forum.com/t/posting-in-admin-namespace/139863/4 "2008-06-08T19:47:50Z")

</div>

Thanks Ryan. That cleared up my problems! I’m getting used to REST and  
assumed that the resource generate script would be reliable for  
models. Eddie, if your are on 2.0, I would still recommend using the  
generate scripts (script generate admin/user) but be careful as they  
are a very rough tool.

-Greg

On Jun 8, 8:31 am, “Ryan B. (Radar)” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
