This project is archived and is in readonly mode.
Named routes with nil params have extra slashes
Reported by Walter Smith | February 14th, 2009 @ 04:49 AM | in 2.x
Define a named route like this:
map.foo '/foo/:id', :controller => 'test', :action => 'foo', :id => nil
In 2.2.2 the following was true:
foo_url ==> "http://host/foo"
url_for(:controller => 'test', :action => 'foo') ==> "http://host/foo"
Now in 2.3RC1 the behavior has changed:
foo_url ==> "http://host/foo/"
url_for(:controller => 'test', :action => 'foo') ==> "http://host/foo"
The trailing slash seems wrong, and in any case the results of foo_url and url_for should be the same, right?
Comments and changes to this ticket
-
josh February 16th, 2009 @ 08:21 PM
- State changed from new to invalid
There should not be a trailing slash by default. I think there is some sort of routing option to configure this though, you may want to check that.
I created a fresh Rails app and it seems to be correct.
posts_path: /posts posts_url: http://localhost:3000/posts url_for(:controller => "posts"): /posts
-
Walter Smith February 16th, 2009 @ 10:03 PM
I did my test with a fresh app too. You don't show the route you used -- it matters whether you have the nil default value in the route. (:id => nil)
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
Referenced by
- 1753 URLs with trailing slashes behave differently in Edge than in 2.2.2 Related #1967?
- 2039 Trailing slashes in URLs causing routing errors in 2.3.0 RC1 for resources declared using ":as" There are a couple possibly related tickets already in th...