diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-10-24 18:08:54 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-10-24 18:08:54 -0500 |
commit | a840c8afbf4e30b7bd9979e8cd70192c65be7a43 (patch) | |
tree | 82ca10172b498a604c051576f51e113eefe9a574 /railties/lib/rails/tasks | |
parent | a0049a6b429c6de46537cc31bf7b3ca48b4c1b2c (diff) | |
download | rails-a840c8afbf4e30b7bd9979e8cd70192c65be7a43.tar.gz rails-a840c8afbf4e30b7bd9979e8cd70192c65be7a43.tar.bz2 rails-a840c8afbf4e30b7bd9979e8cd70192c65be7a43.zip |
Restore `rake routes` [#3402 state:resolved]
Diffstat (limited to 'railties/lib/rails/tasks')
-rw-r--r-- | railties/lib/rails/tasks/routes.rake | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/railties/lib/rails/tasks/routes.rake b/railties/lib/rails/tasks/routes.rake index abbf3258c1..2395d73b2f 100644 --- a/railties/lib/rails/tasks/routes.rake +++ b/railties/lib/rails/tasks/routes.rake @@ -3,16 +3,13 @@ task :routes => :environment do all_routes = ENV['CONTROLLER'] ? ActionController::Routing::Routes.routes.select { |route| route.defaults[:controller] == ENV['CONTROLLER'] } : ActionController::Routing::Routes.routes routes = all_routes.collect do |route| name = ActionController::Routing::Routes.named_routes.routes.index(route).to_s - verb = route.conditions[:method].to_s.upcase - segs = route.segments.inject("") { |str,s| str << s.to_s } - segs.chop! if segs.length > 1 reqs = route.requirements.empty? ? "" : route.requirements.inspect - {:name => name, :verb => verb, :segs => segs, :reqs => reqs} + {:name => name, :verb => route.verb.to_s, :path => route.path, :reqs => reqs} end name_width = routes.collect {|r| r[:name]}.collect {|n| n.length}.max verb_width = routes.collect {|r| r[:verb]}.collect {|v| v.length}.max - segs_width = routes.collect {|r| r[:segs]}.collect {|s| s.length}.max + path_width = routes.collect {|r| r[:path]}.collect {|s| s.length}.max routes.each do |r| - puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:segs].ljust(segs_width)} #{r[:reqs]}" + puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}" end end |