diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-12-17 14:02:44 -0800 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2012-12-17 14:02:44 -0800 |
commit | 60214e80572ca8a4ddb4f2af4a6653efa2e74023 (patch) | |
tree | c3eabd15698fc17805901ca7591013d3513d1462 /railties/lib | |
parent | 504ed9095810c40b0967802dfbdd347c7e3a4e89 (diff) | |
parent | 37d9c44b6d15cc0b02f327fe51687db7d0443bb8 (diff) | |
download | rails-60214e80572ca8a4ddb4f2af4a6653efa2e74023.tar.gz rails-60214e80572ca8a4ddb4f2af4a6653efa2e74023.tar.bz2 rails-60214e80572ca8a4ddb4f2af4a6653efa2e74023.zip |
Merge pull request #8543 from schneems/schneems/html-route-error
Format routes as html on debug page
Diffstat (limited to 'railties/lib')
-rw-r--r-- | railties/lib/rails/info_controller.rb | 1 | ||||
-rw-r--r-- | railties/lib/rails/templates/rails/info/routes.html.erb | 78 |
2 files changed, 5 insertions, 74 deletions
diff --git a/railties/lib/rails/info_controller.rb b/railties/lib/rails/info_controller.rb index ec7d5ed610..e650f58d20 100644 --- a/railties/lib/rails/info_controller.rb +++ b/railties/lib/rails/info_controller.rb @@ -2,6 +2,7 @@ require 'action_dispatch/routing/inspector' class Rails::InfoController < ActionController::Base # :nodoc: self.view_paths = File.expand_path('../templates', __FILE__) + prepend_view_path ActionDispatch::DebugExceptions::RESCUES_TEMPLATE_PATH layout 'application' before_filter :require_local! diff --git a/railties/lib/rails/templates/rails/info/routes.html.erb b/railties/lib/rails/templates/rails/info/routes.html.erb index e34c1c4135..1ea387c63f 100644 --- a/railties/lib/rails/templates/rails/info/routes.html.erb +++ b/railties/lib/rails/templates/rails/info/routes.html.erb @@ -6,77 +6,7 @@ Routes match in priority from top to bottom </p> -<style type='text/css'> - #route_table td {padding: 0 30px;} - #route_table {margin: 0 auto 0;} -</style> - -<table id='route_table' class='route_table'> - <thead> - <tr> - <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> - </tr> - </thead> - <tbody> - <% @routes.each do |route| %> - <tr class='route_row' data-helper='path'> - <td data-route-name='<%= route[:name] %>'> - <% if route[:name].present? %> - <%= route[:name] %><span class='helper'>_path</span> - <% end %> - </td> - <td data-route-verb='<%= route[:verb] %>'> - <%= route[:verb] %> - </td> - <td data-route-path='<%= route[:path] %>'> - <%= route[:path] %> - </td> - <td data-route-reqs='<%= route[:reqs] %>'> - <%= route[:reqs] %> - </td> - </tr> - <% end %> - </tbody> -</table> - -<script type='text/javascript'> - function each(elems, func) { - if (!elems instanceof Array) var elems = [elems]; - for(var i = elems.length; i--; ) { - func(elems[i]); - }; - } - - function setValOn(elems, val) { - each(elems, function(elem) { - elem.innerHTML = val; - }) - } - - function onClick(elems, func) { - each(elems, function(elem) { - elem.onclick = func; - }) - } - - // Enables functionality to toggle between `_path` and `_url` helper suffixes - function setupRouteToggleHelperLinks() { - var toggleLinks = document.querySelectorAll('#route_table [data-route-helper]'); - onClick(toggleLinks, function(){ - var helperTxt = this.getAttribute("data-route-helper"); - var helperElems = document.querySelectorAll('[data-route-name] span.helper'); - setValOn(helperElems, helperTxt); - }) - } - - setupRouteToggleHelperLinks(); - -</script> +<%# actionpack/lib/action_dispatch/middleware/templates %> +<%= render layout: "routes/route_wrapper" do %> + <%= render partial: "routes/route", collection: @routes %> +<% end %> |