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.

when using map.namespace, rails is not properly finding the appropriate namespaced controller

#2897

When using map.namespace like the following, rails is not identifying the proper namespaced controller. (Note: rails default routes were removed)

map.namespace :admin do |admin|
admin.resources :users end

Behavior 1: When UsersController.rb is created under app/controllers and there is no admin folder under app/controller, visiting localhost:3000/admin/users, rails is throwing the following error

NameError in Admin/usersController#index
uninitialized constant Admin

(Expected behavior (atleast to my knowledge): Uninitialized Constant Admin::UsersController)

Behavior 2: When UsersController.rb is created under app/controllers and admin folder is created under app/controller, visiting localhost:3000/admin/users, rails is throwing the following error

NameError in Admin/usersController#index
uninitialized constant Admin::UsersController

(Expected behavior (atleast to my knowledge): Uninitialized Constant Admin::UsersController)

Behavior 3: When UsersController.rb is moved under the admin folder, visiting localhost:3000/admin/users, rails is throwing the following one of the two errors:

TypeError in Admin/usersController#index
superclass mismatch for class UsersController
(or) expected users_controller.rb to define Admin::UsersController
(Expected behavior (atleast to my knowledge): Second Error is OK)

Reported by dharam_sat (at yahoo) · July 10th, 2009 @ 01:31 AM

State: stale
Milestone: 3.x
Assigned to: nobody
Importance: none

Activity

  1. dharam_sat (at yahoo)
    dharam_sat (at yahoo)
    • Tag changed from 2.3.2, rou, routing to 2.3.2, routing

    July 10th, 2009 @ 01:32 AM

  2. dharam_sat (at yahoo)
    dharam_sat (at yahoo)

    Forgot to mention, my Development Environment:

    Rails 2.3.2
    Ruby 1.8.6.26
    No Plugins Installed
    Windows XP

    July 10th, 2009 @ 01:36 AM

  3. Sen
    Sen

    I got the same question here.
    Rails 2.3.2 Ruby 1.8.6.26 under Windows XP too.

    July 21st, 2009 @ 04:29 AM

  4. James R. Bracy
    James R. Bracy

    Same thing here. I have a namespace within a namespace:

    map.namespace :api do |api|
      api.root  :controller => 'documentation', :action => 'show'
      
      api.resource :documentation, :controller => 'documentation'
       
      api.namespace :documentation do |doc|
        doc.resources :flights
      end
    end
    

    My controller are organized like this:

    api/documentation
    api/documentation/flights
    api/flights

    When I go to localhost::3000/api/documentation/flights I get taken to the api/flights controller.

    September 8th, 2009 @ 07:43 PM

  5. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  6. Rohit Arondekar
    Rohit Arondekar
    • State changed from new to stale
    • Importance changed from to

    Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.

    October 9th, 2010 @ 03:59 AM