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.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

resource/resources inside namespace generates wrong routes

#5191

Using latest rails3 edge and the following routes.rb:

Rails.application.routes.draw do |map|
  namespace(:my) do
    resource :text
  end

  map.namespace(:a) do |a|
    a.resource :text
  end
end

Output:

         POST   /my/text(.:format)      {:controller=>"my/texts", :action=>"create"}

new_my_text GET /my/text/new(.:format) {:controller=>"my/texts", :action=>"new"}

         GET    /my/text(.:format)      {:controller=>"my/texts", :action=>"show"}
         PUT    /my/text(.:format)      {:controller=>"my/texts", :action=>"update"}
 my_text DELETE /my/text(.:format)      {:controller=>"my/texts", :action=>"destroy"}

edit_my_text GET /my/text/edit(.:format) {:controller=>"my/texts", :action=>"edit"}

new_a_text GET /a/text/new(.:format) {:controller=>"a/texts", :action=>"new"} edit_a_text GET /a/text/edit(.:format) {:controller=>"a/texts", :action=>"edit"}

  a_text GET    /a/text(.:format)       {:controller=>"a/texts", :action=>"show"}
         PUT    /a/text(.:format)       {:controller=>"a/texts", :action=>"update"}
         DELETE /a/text(.:format)       {:controller=>"a/texts", :action=>"destroy"}
         POST   /a/text(.:format)       {:controller=>"a/texts", :action=>"create"}

As you can see the "my_text" path is on the DELETE method, while the "a_text" path is on the GET method (which is correct!).

Reported by gucki · July 25th, 2010 @ 12:34 PM

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

Activity

  1. gucki
    gucki
    • Tag changed from regression, router to rails3 routes, regression, router

    Nicer display of thew generated routes:

                 GET    /my/text(.:format)      {:action=>"show", :controller=>"my/texts"}
                 POST   /my/text(.:format)      {:action=>"create", :controller=>"my/texts"}
                 PUT    /my/text(.:format)      {:action=>"update", :controller=>"my/texts"}
         my_text DELETE /my/text(.:format)      {:action=>"destroy", :controller=>"my/texts"}
     new_my_text GET    /my/text/new(.:format)  {:action=>"new", :controller=>"my/texts"}
    edit_my_text GET    /my/text/edit(.:format) {:action=>"edit", :controller=>"my/texts"}
    
      new_a_text GET    /a/text/new(.:format)   {:controller=>"a/texts", :action=>"new"}
     edit_a_text GET    /a/text/edit(.:format)  {:controller=>"a/texts", :action=>"edit"}
          a_text GET    /a/text(.:format)       {:controller=>"a/texts", :action=>"show"}
                 PUT    /a/text(.:format)       {:controller=>"a/texts", :action=>"update"}
                 DELETE /a/text(.:format)       {:controller=>"a/texts", :action=>"destroy"}
                 POST   /a/text(.:format)       {:controller=>"a/texts", :action=>"create"}
    

    July 25th, 2010 @ 12:36 PM

  2. gucki
    gucki

    And just for completeness, the same bug is present with resourceS inside namespace:

                 GET    /my/texts(.:format)          {:controller=>"my/texts", :action=>"index"}
        my_texts POST   /my/texts(.:format)          {:controller=>"my/texts", :action=>"create"}
     new_my_text GET    /my/texts/new(.:format)      {:controller=>"my/texts", :action=>"new"}
                 GET    /my/texts/:id(.:format)      {:controller=>"my/texts", :action=>"show"}
                 PUT    /my/texts/:id(.:format)      {:controller=>"my/texts", :action=>"update"}
         my_text DELETE /my/texts/:id(.:format)      {:controller=>"my/texts", :action=>"destroy"}
    edit_my_text GET    /my/texts/:id/edit(.:format) {:controller=>"my/texts", :action=>"edit"}
    
         a_texts GET    /a/texts(.:format)           {:controller=>"a/texts", :action=>"index"}
                 POST   /a/texts(.:format)           {:controller=>"a/texts", :action=>"create"}
      new_a_text GET    /a/texts/new(.:format)       {:controller=>"a/texts", :action=>"new"}
     edit_a_text GET    /a/texts/:id/edit(.:format)  {:controller=>"a/texts", :action=>"edit"}
          a_text GET    /a/texts/:id(.:format)       {:controller=>"a/texts", :action=>"show"}
                 PUT    /a/texts/:id(.:format)       {:controller=>"a/texts", :action=>"update"}
                 DELETE /a/texts/:id(.:format)       {:controller=>"a/texts", :action=>"destroy"}
    

    July 25th, 2010 @ 12:39 PM

  3. gucki
    gucki

    Ok, the bug seems to happen even without namespace:

    Test::Application.routes.draw do |map|
      resources :as
      map.resources :bs
    end
    
           GET    /as(.:format)          {:controller=>"as", :action=>"index"}
        as POST   /as(.:format)          {:controller=>"as", :action=>"create"}
     new_a GET    /as/new(.:format)      {:controller=>"as", :action=>"new"}
           GET    /as/:id(.:format)      {:controller=>"as", :action=>"show"}
           PUT    /as/:id(.:format)      {:controller=>"as", :action=>"update"}
         a DELETE /as/:id(.:format)      {:controller=>"as", :action=>"destroy"}
    edit_a GET    /as/:id/edit(.:format) {:controller=>"as", :action=>"edit"}
    
        bs GET    /bs(.:format)          {:controller=>"bs", :action=>"index"}
           POST   /bs(.:format)          {:controller=>"bs", :action=>"create"}
     new_b GET    /bs/new(.:format)      {:controller=>"bs", :action=>"new"}
    edit_b GET    /bs/:id/edit(.:format) {:controller=>"bs", :action=>"edit"}
         b GET    /bs/:id(.:format)      {:controller=>"bs", :action=>"show"}
           PUT    /bs/:id(.:format)      {:controller=>"bs", :action=>"update"}
           DELETE /bs/:id(.:format)      {:controller=>"bs", :action=>"destroy"}
    

    July 25th, 2010 @ 12:48 PM

  4. gucki
    gucki
    • Tag changed from rails3 routes, regression, router to rails3 routes, patch, regression, router

    The attached patch seems to fix the bugs for me. Please review :-)

    July 25th, 2010 @ 01:24 PM

  5. gucki
    gucki

    Hm, lighthouse seems to have some troubles with the attached file. Here it is again.

    July 25th, 2010 @ 01:26 PM

  6. gucki
    gucki

    As the attachment is still not loading, here as a pastie: http://pastie.org/1059180

    July 25th, 2010 @ 01:31 PM

  7. Rohit Arondekar
    Rohit Arondekar
    • Importance changed from to Low

    Any updates here? Is this still an issue?

    October 15th, 2010 @ 11:05 AM

  8. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open

    This issue has been automatically marked as stale because it has not been commented on for at least three months.

    The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.

    Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.

    February 2nd, 2011 @ 04:30 PM

  9. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:30 PM