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.

polymorphic_url should allow a symbol in place of a record

#1384

After #1317 polymorphic_url should compact given array was committed I found it necessary to send an array of symbols to polymorphic_url() such as:


polymorphic_path([:new, @project, @filter, :issue])

Expecting this to return new_project_issue_path(@project). Instead extract_namespace would empty the array and extract_record() would return nil.

I've patched extract_namespace() to skip the last record if it is a symbol and added a test.

Thanks,

sob

Reported by sob · November 16th, 2008 @ 06:20 AM

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

Activity

  1. Pratik
  2. Michael Koziarski
    Michael Koziarski
    • Milestone changed from 2.x to 2.3.4

    June 9th, 2009 @ 09:40 AM

  3. José Valim
    José Valim
    • Assigned user changed from DHH to José Valim
    • Tag changed from patch, ploymorphic to bugmash, patch, ploymorphic

    I think tests should be improved. They don't relate with the conditions specified in the subject (where we have nil as argument).

    August 9th, 2009 @ 10:15 PM

  4. Dan Croak
    Dan Croak

    verified patch does not apply on 2-3-stable

    August 10th, 2009 @ 04:36 AM

  5. Elise Huard
    Elise Huard

    patch did not apply on current 2-3-stable nor master.
    polymorphic URL have been moved.

    moved the test, and ran it, which generated an error. Then i applied the fix, which corrected the error. So it seems to work.
    Since things moved, i expect it to only run on master.

    August 15th, 2009 @ 02:51 PM

  6. Brendon
    Brendon

    Is this also why:

    form_for @user_session, [:admin, :user_session]

    will try to find admin_user_session_nil_class_path?

    Seems to only happen when there is no model in the array. I know I can do admin_user_session_path, but I can't see why this can't work also, especially since UserSession in my case isn't an AR model, it's an authlogic model.

    August 31st, 2009 @ 11:20 AM

  7. José Valim
    José Valim
    • Assigned user changed from José Valim to Jeremy Kemper

    Thanks Brendon for you input, now I can understand the original ticket.

    Actually, the extract_namespace logic is duplicated inside build_named_route_call, so I was able to remove all extract_namespace method (including the break hax) and make the test pass. Patch is attached.

    August 31st, 2009 @ 02:01 PM

  8. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.3.4 to 2.3.6

    [milestone:id#50064 bulk edit command]

    September 11th, 2009 @ 11:04 PM

  9. José Valim
  10. José Valim
  11. Repository
  12. Repository
  13. José Valim
    José Valim
    • State changed from new to resolved

    November 1st, 2009 @ 12:15 PM