aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/tasks
diff options
context:
space:
mode:
authorHendy Tanata <htanata@gmail.com>2011-07-15 01:54:59 +0800
committerHendy Tanata <htanata@gmail.com>2011-07-16 04:23:05 +0800
commit193e4de20646a025bf6dd3f90d1f9a53edb1cecf (patch)
tree8edc77c9475262ef0308de17d01c21b119cab707 /railties/lib/rails/tasks
parentf88e9d83f13c7d29120696d7e568fae1efea67f4 (diff)
downloadrails-193e4de20646a025bf6dd3f90d1f9a53edb1cecf.tar.gz
rails-193e4de20646a025bf6dd3f90d1f9a53edb1cecf.tar.bz2
rails-193e4de20646a025bf6dd3f90d1f9a53edb1cecf.zip
Better formatting of route requirements in rake:routes.
Previously it was: {:controller=>"photos", :action=>"show", :id=>/[A-Z]\d{5}/} Now it becomes: photos#show {:id=>/[A-Z]\d{5}/}
Diffstat (limited to 'railties/lib/rails/tasks')
-rw-r--r--railties/lib/rails/tasks/routes.rake10
1 files changed, 9 insertions, 1 deletions
diff --git a/railties/lib/rails/tasks/routes.rake b/railties/lib/rails/tasks/routes.rake
index a0c953967c..adc005769f 100644
--- a/railties/lib/rails/tasks/routes.rake
+++ b/railties/lib/rails/tasks/routes.rake
@@ -11,7 +11,15 @@ task :routes => :environment do
reqs = route.requirements.dup
reqs[:to] = route.app unless route.app.class.name.to_s =~ /^ActionDispatch::Routing/
- reqs = reqs.empty? ? "" : reqs.inspect
+
+ controller_action = "#{reqs[:controller]}##{reqs[:action]}"
+ constraints = reqs.except(:controller, :action)
+
+ reqs = controller_action == '#' ? '' : controller_action
+
+ unless constraints.empty?
+ reqs = reqs.empty? ? constraints.inspect : "#{reqs} #{constraints.inspect}"
+ end
{:name => route.name.to_s, :verb => route.verb.to_s, :path => route.path, :reqs => reqs}
end