aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails
diff options
context:
space:
mode:
authorSteve Klabnik <steve@steveklabnik.com>2012-12-13 08:30:51 -0800
committerSteve Klabnik <steve@steveklabnik.com>2012-12-13 08:30:51 -0800
commitae68fc3864e99ab43c18fd12577744e1583f6b64 (patch)
tree5e99366d7f1f930d563f6c58b481e29f6376aa07 /railties/lib/rails
parent0262a18c7b0ab6f60fee842b3007388f9ffeb0fa (diff)
parent08d7b186fde6ec1e7779349a6ff00e34b30f294d (diff)
downloadrails-ae68fc3864e99ab43c18fd12577744e1583f6b64.tar.gz
rails-ae68fc3864e99ab43c18fd12577744e1583f6b64.tar.bz2
rails-ae68fc3864e99ab43c18fd12577744e1583f6b64.zip
Merge pull request #8499 from schneems/schneems/html-route-inspector
Output routes in :html format
Diffstat (limited to 'railties/lib/rails')
-rw-r--r--railties/lib/rails/info_controller.rb2
-rw-r--r--railties/lib/rails/templates/rails/info/routes.html.erb27
2 files changed, 27 insertions, 2 deletions
diff --git a/railties/lib/rails/info_controller.rb b/railties/lib/rails/info_controller.rb
index fe1e25d88c..8ffb56a522 100644
--- a/railties/lib/rails/info_controller.rb
+++ b/railties/lib/rails/info_controller.rb
@@ -16,7 +16,7 @@ class Rails::InfoController < ActionController::Base
def routes
inspector = ActionDispatch::Routing::RoutesInspector.new
- @info = inspector.format(_routes.routes).join("\n")
+ @info = inspector.format(_routes.routes, nil, :html)
end
protected
diff --git a/railties/lib/rails/templates/rails/info/routes.html.erb b/railties/lib/rails/templates/rails/info/routes.html.erb
index 890f6f5b03..8a7e4d37a0 100644
--- a/railties/lib/rails/templates/rails/info/routes.html.erb
+++ b/railties/lib/rails/templates/rails/info/routes.html.erb
@@ -1,3 +1,7 @@
+<style>
+.route-row td {padding: 0 30px;}
+.routeTable {margin: 0 auto 0;}
+</style>
<h2>
Routes
</h2>
@@ -6,4 +10,25 @@
Routes match in priority from top to bottom
</p>
-<p><pre><%= @info %></pre></p> \ No newline at end of file
+<table id='routeTable' class='routeTable'>
+ <th>Helper<br />
+ <%= link_to "Path", "#", 'data-route-helper' => 'path',
+ title: "Returns a relative path (without the http or domain)" %> /
+ <%= link_to "Url", "#", 'data-route-helper' => 'url',
+ title: "Returns an absolute url (with the http and domain)" %>
+ </th>
+ <th>HTTP Verb</th>
+ <th>Path</th>
+ <th>Controller#Action</th>
+ <%= @info.html_safe %>
+</table>
+
+<script type='text/javascript'>
+ $(document).ready(function (){
+ $("#routeTable [data-route-helper]").on('click', function(){
+ routeHelper = $(this).data("route-helper");
+ $('.route-name span.helper').html("_" + routeHelper);
+ return false;
+ })
+ })
+</script> \ No newline at end of file