# How to do models and tests for users\_controller in admin folder/namespace

**URL:** <https://www.ruby-forum.com/t/how-to-do-models-and-tests-for-users-controller-in-admin-folder-namespace/129575>\
**Category:** Rails\
**Created:** [February 19, 2008, 8:12pm UTC](https://www.ruby-forum.com/t/how-to-do-models-and-tests-for-users-controller-in-admin-folder-namespace/129575 "2008-02-19T20:12:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tonypm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/a587f6/32.png) [@tonypm](https://www.ruby-forum.com/u/tonypm)\
**Post date:** [February 19, 2008, 8:12pm UTC](https://www.ruby-forum.com/t/how-to-do-models-and-tests-for-users-controller-in-admin-folder-namespace/129575/1 "2008-02-19T20:12:38Z")

</div>

I thought I was getting somewhere with this, but there is clearly  
something I am not grasping, or I am driving in the wrong direction.

I am tidying up an application, and rebuilding it under rails 2.

I thought it would be a good move to put my admin functions under an  
admin section so that for example, users can be managed in an admin/  
users controller.

Now I thought I had got this figured out because I got the routing  
working by doing this:

map.connect ‘/main’, :controller=\>‘main’  
map.connect ‘/main/clear\_prompt’,  
:controller=\>‘main’,  
:action=\>‘clear\_prompt’  
map.namespace :admin do |admin|  
admin.resources :users  
admin.connect ‘/main’, :controller=\>‘main’  
end

I have a main controller both at the top level and in the admin  
namespace. This seems ok with the above routes. User routing works  
using admin\_user\_path etc. ie. I can use User.find in the controller  
without any problem.

## BUT, I have run into trouble trying to set up tests. These got put under admin/user as I guess I should have expected. But the test setup appears to be looking for a table called admin\_users. Now I dont really want to call it that. Am I going to be stuck with changing the table name, or is there a way of setting up the tests so that it uses users and not admin\_users as the table. ---------- Error message when running unit tests test\_truth(CustomersTest): ActiveRecord::StatementInvalid: Mysql::Error: Table ‘italk\_test.admin\_users’ doesn’t exist: DELETE FROM `admin_users`

Or am I misunderstanding the whole thing?

Thanks for any help  
Tonypm
