aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/CHANGELOG4
-rw-r--r--actionpack/lib/action_controller/routing.rb4
-rw-r--r--actionpack/test/controller/routing_test.rb10
3 files changed, 15 insertions, 3 deletions
diff --git a/actionpack/CHANGELOG b/actionpack/CHANGELOG
index 1d28af1c3d..d4ff4b0373 100644
--- a/actionpack/CHANGELOG
+++ b/actionpack/CHANGELOG
@@ -1,5 +1,9 @@
*SVN*
+* Small fix in routing to allow dynamic routes (broken after [4242]) [Rick]
+
+ map.connect '*path', :controller => 'files', :action => 'show'
+
* Replace alias method chaining with Module#alias_method_chain. [Marcel Molina Jr.]
* Replace Ruby's deprecated append_features in favor of included. [Marcel Molina Jr.]
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index d0726e8a8b..f52b78cc75 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -329,8 +329,8 @@ module ActionController
def write_recognition(g)
raise RoutingError, "Path components must occur last" unless g.after.empty?
- start = g.index_name
- start = "(#{start})" unless /^\w+$/ =~ start
+ start = g.index_name.to_s
+ start = "(#{start})" unless /^\w+$/ =~ start.to_s
value_expr = "#{g.path_name}[#{start}..-1] || []"
g.result key, "ActionController::Routing::PathComponent::Result.new_escaped(#{value_expr})"
diff --git a/actionpack/test/controller/routing_test.rb b/actionpack/test/controller/routing_test.rb
index 136a3dc8e6..4f094a36ff 100644
--- a/actionpack/test/controller/routing_test.rb
+++ b/actionpack/test/controller/routing_test.rb
@@ -823,7 +823,15 @@ class RouteSetTests < Test::Unit::TestCase
rs.connect ':controller/:action/:id'
end
end
-
+
+ def test_dynamic_path_allowed
+ rs.draw do |map|
+ rs.connect '*path', :controller => 'content', :action => 'show_file'
+ end
+
+ assert_equal ['/pages/boo', []], rs.generate(:controller => 'content', :action => 'show_file', :path => %w(pages boo))
+ end
+
def test_backwards
rs.draw do |map|
rs.connect 'page/:id/:action', :controller => 'pages', :action => 'show'