I've added two namespaces into my routes that split the public and admin areas respectively. The idea is that they share models but the views and controllers are different for each namespace.
My admin namespace is /admin and my public namespace is just /
So...
map.namespace :admin, :path_prefix => "/admin", :name_prefix => "admin_" do |admin|
map.namespace :public, :path_prefix => "", :name_prefix => "" do |pub|
Now, this works, but I've noticed that when I have nested resources with shallow routes, the /public prefix ends up showing up in the routes table (for both the path and the name)
pub.resources :plans,
:name_prefix => "",
:path_prefix => "",
:shallow => true,
:collection => {
:search => [:get,:post]
} do |plan|
# /plans/:id/phases
plan.resources :phases,
:shallow => true,
:name_prefix => "",
:path_prefix => "",
:collection => {
:search => [:get,:post]
} do |phase|
end
end
The routing table for this segment looks like so:
search_plans GET /plans/search(.:format) {:controller=>"public/plans", :action=>"search"}
POST /plans/search(.:format) {:controller=>"public/plans", :action=>"search"}
plans GET /plans(.:format) {:controller=>"public/plans", :action=>"index"}
POST /plans(.:format) {:controller=>"public/plans", :action=>"create"}
new_plan GET /plans/new(.:format) {:controller=>"public/plans", :action=>"new"}
edit_public_plan GET /public/plans/:id/edit(.:format) {:controller=>"public/plans", :action=>"edit"}
public_plan GET /public/plans/:id(.:format) {:controller=>"public/plans", :action=>"show"}
PUT /public/plans/:id(.:format) {:controller=>"public/plans", :action=>"update"}
DELETE /public/plans/:id(.:format) {:controller=>"public/plans", :action=>"destroy"}
search_phases GET /phases/search(.:format) {:controller=>"public/phases", :action=>"search"}
POST /phases/search(.:format) {:controller=>"public/phases", :action=>"search"}
phases GET /phases(.:format) {:controller=>"public/phases", :action=>"index"}
POST /phases(.:format) {:controller=>"public/phases", :action=>"create"}
new_phase GET /phases/new(.:format) {:controller=>"public/phases", :action=>"new"}
edit_public_phase GET /public/phases/:id/edit(.:format) {:controller=>"public/phases", :action=>"edit"}
public_phase GET /public/phases/:id(.:format) {:controller=>"public/phases", :action=>"show"}
PUT /public/phases/:id(.:format) {:controller=>"public/phases", :action=>"update"}
DELETE /public/phases/:id(.:format) {:controller=>"public/phases", :action=>"destroy"}
For some reason the /public is being added as the prefix to the ID area of the route?
I've tried setting the name_prefix and path_prefix to nil and I've also tried setting up the route with name_prefix respectful to that of its parent (so phases would have name_prefix => "plans/:id" but this doesn't work with the shallow option).
Any ideas as to what's going on? How can I fix this?