This project is archived and is in readonly mode.
Routing with a blank path_prefix causes a bad url to generate
Reported by Andrew Bloom | March 3rd, 2009 @ 10:22 PM | in 2.x
edit Long complex description has been moved to my blog: http://www.somethingunimportant.... I have now updated this ticket to walk you through a simple example to reproduce this bug.
> rails bug
> cd bug
Edit routes.rb to include:
map.connect "/applicants/:id", :controller => "applicants", :action => "show", :path_prefix => ""
> rake routes
(in /Users/abloom/Sites/bug)
//applicants/:id {:controller=>"applicants",
:action=>"show"}
Edit routes.rb to include:
map.connect "/applicants/:id", :controller => "applicants", :action => "show", :path_prefix => nil
> rake routes
(in /Users/abloom/Sites/bug)
/applicants/:id {:controller=>"applicants",
:action=>"show"}
Notice how with the path_prefix set to an empty string the route builder generates an extra slash, but with it set to nil the path looks normal.
Comments and changes to this ticket
-
Andrew Bloom March 4th, 2009 @ 03:48 AM
- Tag changed from 2.x, routing to 2.2, 2.3, edge, patch, routing
previous patch was against tags/2.3.0, this new one is against edge and has more tests.
-
Michael Koziarski March 5th, 2009 @ 08:21 PM
I'm not sure I follow why you're passing an empty string there though? Seems wrong to just silently ignore a value that was passed?
-
Andrew Bloom March 5th, 2009 @ 08:23 PM
The blank string came when trying to build routes like this:
path_prefix = (%w(development test).include?(RAILS_ENV) ? "admin" : "") map.namespace(:admin, :path_prefix => path_prefix) do |admin|
...
end
Yes, it could easily by fixed by making the conditional return nil instead of "", but it still seems like adding the / when there is no slug isn't appropriate.
-
Andrew Bloom March 5th, 2009 @ 08:24 PM
path_prefix = (%w(development test).include?(RAILS_ENV) ? "admin" : "") map.namespace(:admin, :path_prefix => path_prefix) do |admin| ... end
(can we get a preview function on comments before posting them?)
-
CancelProfileIsBroken March 7th, 2009 @ 03:58 PM
I'm +1 on this. We've had two different people hit this, the fixed behavior seems reasonably intuitive and I can't think of anything else we'd want to do with an empty :path_prefix.
-
Repository March 9th, 2009 @ 03:30 PM
- State changed from new to resolved
(from [90dba00822acd1e01f7a39625668ee74ffe5f061]) Ensure blank path_prefix works as expected [#2122 state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com http://github.com/rails/rails/co...
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
Referenced by
- 1571 Routing with empty path_prefix should not add two / to the url Being discussed in #2122
- 2122 Routing with a blank path_prefix causes a bad url to generate (from [90dba00822acd1e01f7a39625668ee74ffe5f061]) Ensure ...