aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/tasks
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2010-08-28 22:53:18 -0300
committerJosé Valim <jose.valim@gmail.com>2010-08-28 22:54:42 -0300
commit82b700a89deffb6526f7fbfd9942f1e723cad9a7 (patch)
tree5d273c06e1706f472e9196dd21982fdfab3535e1 /railties/lib/rails/tasks
parent68a949bae7408dafdfdd28b6c1de25d5348e64c7 (diff)
downloadrails-82b700a89deffb6526f7fbfd9942f1e723cad9a7.tar.gz
rails-82b700a89deffb6526f7fbfd9942f1e723cad9a7.tar.bz2
rails-82b700a89deffb6526f7fbfd9942f1e723cad9a7.zip
Ensure we are not calling length on nil.
Diffstat (limited to 'railties/lib/rails/tasks')
-rw-r--r--railties/lib/rails/tasks/routes.rake9
1 files changed, 4 insertions, 5 deletions
diff --git a/railties/lib/rails/tasks/routes.rake b/railties/lib/rails/tasks/routes.rake
index 2cee84767d..9db8b60969 100644
--- a/railties/lib/rails/tasks/routes.rake
+++ b/railties/lib/rails/tasks/routes.rake
@@ -1,8 +1,7 @@
desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
task :routes => :environment do
Rails.application.reload_routes!
-
- all_routes = Rails.application.routes.routes
+ all_routes = Rails.application.routes.routes
if ENV['CONTROLLER']
all_routes = all_routes.select{ |route| route.defaults[:controller] == ENV['CONTROLLER'] }
@@ -19,9 +18,9 @@ task :routes => :environment do
routes.reject! { |r| r[:path] =~ %r{/rails/info/properties} } # Skip the route if it's internal info route
- name_width = routes.map{ |r| r[:name] }.map(&:length).max
- verb_width = routes.map{ |r| r[:verb] }.map(&:length).max
- path_width = routes.map{ |r| r[:path] }.map(&:length).max
+ name_width = routes.map{ |r| r[:name].length if r[:name] }.max
+ verb_width = routes.map{ |r| r[:verb].length if r[:verb] }.max
+ path_width = routes.map{ |r| r[:path].length if r[:path] }.max
routes.each do |r|
puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}"