Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix creating an empty route on 1.8. Closes #1210

  • Loading branch information...
commit 8a0ffa7c9521c6c8d4298422ae1504d9d839987e 1 parent 1ff4bfc
@dmathieu dmathieu authored
View
4 actionpack/lib/action_dispatch/routing/mapper.rb
@@ -1423,7 +1423,9 @@ def path_for_action(action, path) #:nodoc:
end
def action_path(name, path = nil) #:nodoc:
- path || @scope[:path_names][name.to_sym] || name.to_s
+ # Ruby 1.8 can't transform empty strings to symbols
+ name = name.to_sym if name.is_a?(String) && !name.empty?
+ path || @scope[:path_names][name] || name.to_s
end
def prefix_name_for_action(as, action) #:nodoc:
View
6 actionpack/test/controller/integration_test.rb
@@ -492,6 +492,8 @@ def self.routes
end
routes.draw do
+ match '', :to => 'application_integration_test/test#index', :as => :empty_string
+
match 'foo', :to => 'application_integration_test/test#index', :as => :foo
match 'bar', :to => 'application_integration_test/test#index', :as => :bar
end
@@ -501,11 +503,15 @@ def app
end
test "includes route helpers" do
+ assert_equal '/', empty_string_path
assert_equal '/foo', foo_path
assert_equal '/bar', bar_path
end
test "route helpers after controller access" do
+ get '/'
+ assert_equal '/', empty_string_path
+
get '/foo'
assert_equal '/foo', foo_path
Please sign in to comment.
Something went wrong with that request. Please try again.