Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make rake routes gracefully handle routes with no name

Signed-off-by: Santiago Pastorino <>
  • Loading branch information...
commit 600cf8bebc29da3538032ea141d9881a5ead9b1f 1 parent 82b700a
@rubys rubys authored spastorino committed
Showing with 5 additions and 5 deletions.
  1. +5 −5 railties/lib/rails/tasks/routes.rake
10 railties/lib/rails/tasks/routes.rake
@@ -13,16 +13,16 @@ task :routes => :environment do
reqs[:to] = unless =~ /^ActionDispatch::Routing/
reqs = reqs.empty? ? "" : reqs.inspect
- {:name =>, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
+ {:name =>, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
routes.reject! { |r| r[:path] =~ %r{/rails/info/properties} } # Skip the route if it's internal info route
- name_width ={ |r| r[:name].length if r[:name] }.max
- verb_width ={ |r| r[:verb].length if r[:verb] }.max
- path_width ={ |r| r[:path].length if r[:path] }.max
+ name_width ={ |r| r[:name].length }.max
+ verb_width ={ |r| r[:verb].length }.max
+ path_width ={ |r| r[:path].length }.max
routes.each do |r|
puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"

4 comments on commit 600cf8b


Could somebody give an example of what this commit fixes?


rake routes command was not working with wild routes until this commit.
Thanks to the awesome test suite of Sam Ruby this could be fixed just in time ;).


spastorino: Do you have an example of "wild routes"?


From the comments of the routes file:

# This is a legacy wild controller route that's not recommended for RESTful applications.
# Note: This route will make all actions in every controller accessible via GET requests.
# match ':controller(/:action(/:id(.:format)))'
Please sign in to comment.
Something went wrong with that request. Please try again.