Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Allow routes with a trailing slash to be recognized

Signed-off-by: Michael Koziarski <>
[#2039 state:committed]
  • Loading branch information...
commit ce56c5daa81d61a745b88220014a846a0eea46a4 1 parent 9b1b88f
@ffmike ffmike authored NZKoz committed
2  actionpack/lib/action_controller/routing/segments.rb
@@ -318,7 +318,7 @@ def interpolation_chunk
def regexp_chunk
- '(\.[^/?\.]+)?'
+ '/|(\.[^/?\.]+)?'
def to_s
12 actionpack/test/controller/resources_test.rb
@@ -750,9 +750,17 @@ def test_nested_resources_in_nested_namespace
def test_with_path_segment
- with_restful_routing :messages, :as => 'reviews' do
- assert_simply_restful_for :messages, :as => 'reviews'
+ with_restful_routing :messages do
+ assert_simply_restful_for :messages
+ assert_recognizes({:controller => "messages", :action => "index"}, "/messages")
+ assert_recognizes({:controller => "messages", :action => "index"}, "/messages/")
+ with_restful_routing :messages, :as => 'reviews' do
+ assert_simply_restful_for :messages, :as => 'reviews'
+ assert_recognizes({:controller => "messages", :action => "index"}, "/reviews")
+ assert_recognizes({:controller => "messages", :action => "index"}, "/reviews/")
+ end
def test_multiple_with_path_segment_and_controller

7 comments on commit ce56c5d


Does this mean that previously routes with a trailing slash were not recognized properly?


It means that it worked up to and including 2.2.2, was broken in 2.3.0 RC1, and is now fixed again.


Does this mean 2 different urls for the same resource?… I mean, It’s a bot going to index those urls as duplicated content?


@Wincent: that’s what I meant ;-) But thanks for clarifying. This explains some weirdness I’ve been experiencing with a Rails Edge project.

@Yizzreel: Depends entirely on the bot. Technically the URLs point to one and identical resource, so the URLs should be treated as the same, yes.


@ariejan I’ve been reading a bit about this concern in Google’s webmaster tools. There’s an article in the help section about duplicated content I’ll put an important note in this article

Be consistent: Try to keep your internal linking consistent. For example, don’t link to and and

This mean that and are not the same url, therefore are not the same resource, therefore are duplicated content.

However, this problem would be important only if you include both url formats in your application, and link helpers will always generate ‘/’-less urls


In my previous comment, the paragrapth “Be consistent: …” is extracted from google help section (I tried to use textile ‘bq. ’ but it doesn’t work)


If you’re concerned about two URLs pointing to the same resource, consider using the new canonical URL meta tag:

Please sign in to comment.
Something went wrong with that request. Please try again.