Namespaced routing + AJAX issues

Hi Im a newbie so please bear with me.

I’ve two controllers admin and public.

The admin controller inherits from the public controller.

I have two problems

The controller returns method admin_admin_hierarchies_path not found. If
I remove the redirect_to {[:admin, hierarchies]} and make it
{hierarchies} I can get it to work, but the return from the ajax call
tries to access the new method of the public hierarchies controller, and
since there isn’t a method for that in the new controller it fails.

undefined method `admin_admin_hierarchies_url’ for
#Admin::HierarchiesController:0x47f90f0

app/controllers/admin/hierarchies_controller.rb:13:in new' app/controllers/admin/hierarchies_controller.rb:12:innew’

routes.rb

ActionController::Routing::Routes.draw do |map|
map.resources :hierarchies

map.root :controller => ‘sessions’
map.resources :sessions
map.resource :session, :controller => ‘sessions’
map.login ‘/login’, :controller => ‘sessions’, :action => ‘new’
map.logout ‘/logout’, :controller => ‘sessions’, :action => ‘destroy’
map.namespace(:admin) do |admin|
admin.resources :hierarchies
end

map.connect ‘:controller/:action/:id.:format’
map.connect ‘:controller/:action/:id’
map.connect ‘:controller/:action/:sort/:order’
end

class Admin::HierarchiesController < HierarchiesController

layout ‘admin’
skip_before_filter :login_required
before_filter :admin_required, :except => [:filterhierarchies]

GET /admin_hierarchies/new

GET /admin_hierarchies/new.xml

def new
@hierarchy = Admin::Hierarchy.new
@hierarchy_company = Company.find(:all, :order => “id”)
respond_to do |format|
format.html { redirect_to([:admin,@hierarchy]) }
format.xml { render :xml => @hierarchy }
end
end
def filterhierarchies
respond_to do |want|
@co_business_streams = BusinessStream.search(params[:company_id])
want.js{
render :update do |page|
page.replace_html ‘hierarchy_business_stream_id’, :partial =>
‘filterhierarchies’
end
}
end
end