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.

controller generator w/ module/namespace generates incorrect routes

#6139

Generating a controller in a module/namespace is advertised by the generator help text, but the generated routes are incorrect.

For example:
rails g controller One/Two edit index new show generates four separate routes:

get "two/edit"
get "two/index"
get "two/new"
get "two/show"

...and the accompanying functional tests fail.

It should really generate four namespaced routes:

namespace :one do
  get "two/edit"
  get "two/index"
  get "two/new"
  get "two/show"
end

...so the accompanying generated functional tests pass!

Reported by Tim McEwan · December 9th, 2010 @ 01:02 PM

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

Activity

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

    Since the generated routes are pretty much always going to be rewritten and it isn't necessarily the case that a namespaced controller is namespaced within the url I don't think that it's worth the development effort to get this to work. I do appreciate that we are generating tests that are broken out of the box but the generated code is a starting point and not the finished article.

    Additionally with namespaced engines coming in Rails 3.1 there'll be even more instances where a namespaced controller does not namespace its urls - in fact there's even a test to ensure that it doesn't.

    February 14th, 2011 @ 01:04 PM