This project is archived and is in readonly mode.

#2897 ✓stale
dharam_sat (at yahoo)

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

Reported by dharam_sat (at yahoo) | July 10th, 2009 @ 01:31 AM | in 3.x

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)

Comments and changes to this ticket

  • dharam_sat (at yahoo)

    dharam_sat (at yahoo) July 10th, 2009 @ 01:32 AM

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

    dharam_sat (at yahoo) July 10th, 2009 @ 01:36 AM

    Forgot to mention, my Development Environment:

    Rails 2.3.2
    Ruby 1.8.6.26
    No Plugins Installed
    Windows XP

  • Sen

    Sen July 21st, 2009 @ 04:29 AM

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

  • James R. Bracy

    James R. Bracy September 8th, 2009 @ 07:43 PM

    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.

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • Rohit Arondekar

    Rohit Arondekar October 9th, 2010 @ 03:59 AM

    • 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.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Tags

Pages