Skip to content
This repository
Browse code

Read the route name directly from the route instead of looking it up …

…in the named routes hash

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
  • Loading branch information...
commit 5c2b6c55a08564bd6ee36a25c8155e90f002306a 1 parent dda515f
Andrew White pixeltrix authored jeremy committed

Showing 1 changed file with 1 addition and 7 deletions. Show diff stats Hide diff stats

  1. +1 7 railties/lib/rails/tasks/routes.rake
8 railties/lib/rails/tasks/routes.rake
@@ -3,24 +3,18 @@ task :routes => :environment do
3 3 Rails.application.reload_routes!
4 4
5 5 all_routes = Rails.application.routes.routes
6   - named_routes = Rails.application.routes.named_routes.routes
7 6
8 7 if ENV['CONTROLLER']
9 8 all_routes = all_routes.select{ |route| route.defaults[:controller] == ENV['CONTROLLER'] }
10 9 end
11 10
12 11 routes = all_routes.collect do |route|
13   - # TODO: The :index method is deprecated in 1.9 in favor of :key
14   - # but we don't have :key in 1.8.7. We can remove this check when
15   - # stop supporting 1.8.x
16   - key = Hash.method_defined?('key') ? 'key' : 'index'
17   - name = named_routes.send(key, route).to_s
18 12
19 13 reqs = route.requirements.dup
20 14 reqs[:to] = route.app unless route.app.class.name.to_s =~ /^ActionDispatch::Routing/
21 15 reqs = reqs.empty? ? "" : reqs.inspect
22 16
23   - {:name => name, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
  17 + {:name => route.name, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
24 18 end
25 19
26 20 routes.reject! { |r| r[:path] =~ %r{/rails/info/properties} } # Skip the route if it's internal info route

0 comments on commit 5c2b6c5

Please sign in to comment.
Something went wrong with that request. Please try again.