This project is archived and is in readonly mode.

polymorphic_url should allow a symbol in place of a record
Reported by sob | November 16th, 2008 @ 06:20 AM | in 2.3.6
After #1317 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
Comments and changes to this ticket
- 
         
- 
         Michael Koziarski June 9th, 2009 @ 09:40 AM- Milestone changed from 2.x to 2.3.4
 
- 
         José Valim August 9th, 2009 @ 10:15 PM- 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). 
- 
            
         
- 
            
        Elise Huard August 15th, 2009 @ 02:51 PMpatch 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.
- 
            
         Brendon August 31st, 2009 @ 11:20 AMIs 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. 
- 
         José Valim August 31st, 2009 @ 02:01 PM- 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. 
- 
         Jeremy Kemper September 11th, 2009 @ 11:04 PM- Milestone changed from 2.3.4 to 2.3.6
 [milestone:id#50064 bulk edit command] 
- 
         
- 
         
- 
         Repository October 28th, 2009 @ 07:13 PM(from [427a7385eb9b784ad4372bf607217b0b7b2ca543]) Make polymorphic_url work with symbols again and refactor it [#1384 status:resolved] Signed-off-by: Joshua Peek josh@joshpeek.com 
 http://github.com/rails/rails/commit/427a7385eb9b784ad4372bf607217b...
- 
         Repository October 28th, 2009 @ 07:15 PM(from [7ba80252a5a6bd94c8445347caee663b12c1a526]) Make polymorphic_url work with symbols again and refactor it [#1384 status:resolved] Signed-off-by: Joshua Peek josh@joshpeek.com 
 http://github.com/rails/rails/commit/7ba80252a5a6bd94c8445347caee66...
- 
         José Valim November 1st, 2009 @ 12:15 PM- State changed from new to resolved
 
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>
People watching this ticket
Attachments
Tags
Referenced by
- 
         1384 
          polymorphic_url should allow a symbol in place of a record
        (from [427a7385eb9b784ad4372bf607217b0b7b2ca543])
Make po... 1384 
          polymorphic_url should allow a symbol in place of a record
        (from [427a7385eb9b784ad4372bf607217b0b7b2ca543])
Make po...
- 
         1384 
          polymorphic_url should allow a symbol in place of a record
        (from [7ba80252a5a6bd94c8445347caee663b12c1a526])
Make po... 1384 
          polymorphic_url should allow a symbol in place of a record
        (from [7ba80252a5a6bd94c8445347caee663b12c1a526])
Make po...
 charly71
      charly71
 DHH
      DHH
 Ian White
      Ian White
 Jeremy Kemper
      Jeremy Kemper
 José Valim
      José Valim
 Katherine G Pe
      Katherine G Pe
 Michael Koziarski
      Michael Koziarski
 Pratik
      Pratik
 sob
      sob
 Tsutomu Kuroda
      Tsutomu Kuroda