diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2011-12-26 11:31:22 +0100 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2011-12-26 11:54:27 +0100 |
commit | d7cfb636367f2f929d07ade9060d35a2cf7ad20b (patch) | |
tree | 7a59f0e134e73e9ce882cbef389d4387315986ac /railties/lib | |
parent | 4cf40d04e4193494b4854c771f78a105aeee8e76 (diff) | |
download | rails-d7cfb636367f2f929d07ade9060d35a2cf7ad20b.tar.gz rails-d7cfb636367f2f929d07ade9060d35a2cf7ad20b.tar.bz2 rails-d7cfb636367f2f929d07ade9060d35a2cf7ad20b.zip |
Correctly display rack apps with dynamic constraints in RoutesInspector
If you used dynamic constraint like that:
scope :constraint => MyConstraint.new do
mount RackApp => "/foo"
end
routes were not displayed correctly when using `rake routes`.
This commit fixes it. If you want nice display of dynamic
constraints in `rake routes` output, please just override
to_s method in your constraint's class.
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/application/route_inspector.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/railties/lib/rails/application/route_inspector.rb b/railties/lib/rails/application/route_inspector.rb index 26652a8e5e..3e08b78221 100644 --- a/railties/lib/rails/application/route_inspector.rb +++ b/railties/lib/rails/application/route_inspector.rb @@ -23,7 +23,7 @@ module Rails routes = routes.collect do |route| route_reqs = route.requirements - rack_app = route.app unless route.app.class.name.to_s =~ /^ActionDispatch::Routing/ + rack_app = discover_rack_app(route.app) controller = route_reqs[:controller] || ':controller' action = route_reqs[:action] || ':action' @@ -70,6 +70,15 @@ module Rails "#{r[:name].rjust(name_width)} #{r[:verb].ljust(verb_width)} #{r[:path].ljust(path_width)} #{r[:reqs]}" end end + + def discover_rack_app(app) + class_name = app.class.name.to_s + if class_name == "ActionDispatch::Routing::Mapper::Constraints" + discover_rack_app(app.app) + elsif class_name !~ /^ActionDispatch::Routing/ + app + end + end end end end |