tonypm
2008-Feb-19 19:11 UTC
how to do models and tests for users_controller in admin folder/namespace
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 --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---