Permalink
Browse files

Small fix in routing to allow dynamic routes (broken after [4242]) [R…

…ick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4319 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 325cb12 commit 04ef7f4be6c26e35947f2dd3e4dfbd1eb73c9933 @technoweenie technoweenie committed Apr 30, 2006
View
@@ -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.]
@@ -329,8 +329,8 @@ def write_generation(g)
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})"
@@ -823,7 +823,15 @@ def test_paths_do_not_accept_defaults
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'

0 comments on commit 04ef7f4

Please sign in to comment.