def index
unless params[:path].blank?
@path = params[:path]
@route = ActionController::Routing::Routes.recognize_path(@path)
end
@routes = ActionController::Routing::Routes.routes.collect do |route|
name = ActionController::Routing::Routes.named_routes.routes.index(route).to_s
verb = route.conditions[:method].to_s.upcase
segs = route.segments.inject("") { |str,s| str << s.to_s }
segs.chop! if segs.length > 1
reqs = route.requirements.empty? ? "" : route.requirements.inspect
{:name => name, :verb => verb, :segs => segs, :reqs => reqs}
end
<div style="margin: 10px 0">
<% form_tag cms_routes_path, :method => :get do %>
<label>
Path to Test: <%= text_field_tag :path, @path, :size => 50 %>
</label>
<% unless @route.blank? %>
<div style="margin: 10px 0">
<%=h @route.inspect %>
</div>
<% end %>
<% end %>
</div>
<table class="data">
<tr>
<th class="first"></th>
<th><div class="dividers">Name</div></th>
<th><div class="dividers">Verb</div></th>
<th><div class="dividers">Pattern</div></th>
<th><div class="dividers">Result</div></th>
<th class="last"></th>
</tr>
<% for route in @routes %><tr>
<td class="first"></td>
<td><%=h route[:name] %></td>
<td><%=h route[:verb] %></td>
<td><%=h route[:segs] %></td>
<td><%=h route[:reqs] %></td>
<td class="last"></td>
</tr><% end %>
</table>
[img]http://bot.iteye.com/upload/picture/pic/38388/4847c8cf-339e-353b-b8d8-c260cc760753.jpg[/img]