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.

Named routes with nil params have extra slashes

#1967

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?

Reported by Walter Smith · February 14th, 2009 @ 04:49 AM

State: invalid
Milestone: 2.x
Assigned to: josh josh
Importance: none

Activity

  1. josh
    josh
    • 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
    

    February 16th, 2009 @ 08:21 PM

  2. josh
  3. Walter Smith
    Walter Smith

    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)

    February 16th, 2009 @ 10:03 PM