Skip to content

Commit

Permalink
Add option to routes task to target a specific controller with CONTRO…
Browse files Browse the repository at this point in the history
…LLER=x.

Signed-off-by: Michael Koziarski <michael@koziarski.com>
[#2928 state:committed]
  • Loading branch information
hardbap authored and NZKoz committed Aug 8, 2009
1 parent f73d34c commit 1c6c216
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions railties/lib/tasks/routes.rake
@@ -1,6 +1,7 @@
desc 'Print out all defined routes in match order, with names.'
desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
task :routes => :environment do
routes = ActionController::Routing::Routes.routes.collect do |route|
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 }
Expand All @@ -14,4 +15,4 @@ task :routes => :environment do
routes.each do |r|
puts "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:segs].ljust(segs_width)} #{r[:reqs]}"
end
end
end

0 comments on commit 1c6c216

Please sign in to comment.