File tree 1 file changed +4
-3
lines changed
1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 1
- desc 'Print out all defined routes in match order, with names.'
1
+ desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x. '
2
2
task :routes => :environment do
3
- routes = ActionController ::Routing ::Routes . routes . collect do |route |
3
+ all_routes = ENV [ 'CONTROLLER' ] ? ActionController ::Routing ::Routes . routes . select { |route | route . defaults [ :controller ] == ENV [ 'CONTROLLER' ] } : ActionController ::Routing ::Routes . routes
4
+ routes = all_routes . collect do |route |
4
5
name = ActionController ::Routing ::Routes . named_routes . routes . index ( route ) . to_s
5
6
verb = route . conditions [ :method ] . to_s . upcase
6
7
segs = route . segments . inject ( "" ) { |str , s | str << s . to_s }
@@ -14,4 +15,4 @@ task :routes => :environment do
14
15
routes . each do |r |
15
16
puts "#{ r [ :name ] . rjust ( name_width ) } #{ r [ :verb ] . ljust ( verb_width ) } #{ r [ :segs ] . ljust ( segs_width ) } #{ r [ :reqs ] } "
16
17
end
17
- end
18
+ end
You can’t perform that action at this time.
0 commit comments