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.

route generation fails with :module written in Symbol

#4899

Named route is not generated since a Symbol defining module name won't be converted to String.

This might be a regression caused by commit:6db9558416cf2133adacbe1634f28c25bfe618d6

I attached a patch to fix this with a test.

This is a stack trace with my app which where working just before the commit above.

$ rake test (in /home/fujimura/a_project) /home/fujimura/src/rails/actionpack/lib/action_dispatch/routing/mapper.rb:874:in
name_for_action': undefined methodtr' for :users:Symbol (NoMethodError)

    from /home/fujimura/src/rails/actionpack/lib/action_dispatch/routing/mapper.rb:868:in `options_for_action'
    from /home/fujimura/src/rails/actionpack/lib/action_dispatch/routing/mapper.rb:722:in `match'
    from /home/fujimura/src/rails/actionpack/lib/action_dispatch/routing/mapper.rb:287:in `map_method'
    from /home/fujimura/src/rails/actionpack/lib/action_dispatch/routing/mapper.rb:239:in `get'
    from /home/fujimura/a_project/config/routes.rb:38

Reported by Daisuke Fujimura · June 18th, 2010 @ 01:37 PM

State: resolved
Milestone: none
Assigned to: Jeremy Kemper Jeremy Kemper
Importance: none

Activity

  1. Andrew White
    Andrew White

    Daisuke, the same problem occurs in the nested scope as well - can you fix it there and upload a new patch (with extra tests for the nested scope)?

    Failing routes:

      scope(:module => :admin) do
        resources :products do
          resources :images
        end
      end
    

    June 18th, 2010 @ 05:35 PM

  2. Andrew White
    Andrew White
    • Assigned user set to Jeremy Kemper

    Actually, don't bother Daisuke - this is actually a symptom of a deeper problem. I was using :module to try and determine the shallow path and name prefix. As your example illustrates :module may not actually be part of the namespace so it needs to be fixed in a different way.

    The attached patch fixes this problem by tracking the shallow path and name prefix properly and modifies an existing test route to use a symbol for :module so that we don't get a regression.

    June 19th, 2010 @ 01:02 PM

  3. Repository
    Repository
    • State changed from new to resolved

    (from [1f84061c5c271647dc5f7f1311e365e134130e0f]) Don't use module to work out shallow name prefix and path as it may not accurately reflect the actual namespace [#4899 route generation fails with :module written in Symbol state:resolved]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/1f84061c5c271647dc5f7f1311e365...

    June 19th, 2010 @ 11:19 PM