Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

namespace nested in resource

#5609
  resources :units do
    resources :packages, :controller => "units/packages"
    namespace :admin do
      resources :groups, :controller => "units/admin/groups"
      resources :packages, :controller => "units/admin/packages" do
        resources :share_packages, :controller => "units/admin/share_packages"
      end
    end
  end

This seems correct (works in development mode Rails 3.0.0), but causes exception in production mode:
"ActionController::RoutingError (uninitialized constant Admin::Units):"

I dont know how to fix it other then this little trick with "resource":

  resources :units do
    resources :packages, :controller => "units/packages"
    resource :admin do
      resources :groups, :controller => "units/admin/groups"
      resources :packages, :controller => "units/admin/packages" do
        resources :share_packages, :controller => "units/admin/share_packages"
      end
    end
  end

Reported by Tomasz Bak · September 10th, 2010 @ 06:57 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Andrew White
    Andrew White
    • State changed from new to invalid
    • Importance changed from to Low

    The namespace option nests the controller class whereas the resource call doesn't. In production mode the app path is eagerly loaded triggering the error. If you don't want the nested class then pass in nil for the module option:

      resources :units do
        resources :packages, :controller => "units/packages"
        namespace :admin, :module => nil do
          resources :groups, :controller => "units/admin/groups"
          resources :packages, :controller => "units/admin/packages" do
            resources :share_packages, :controller => "units/admin/share_packages"
          end
        end
      end
    

    September 12th, 2010 @ 01:04 AM