Skip to content

Instantly share code, notes, and snippets.

@toxaq
Created October 31, 2013 11:39
Show Gist options
  • Save toxaq/7248280 to your computer and use it in GitHub Desktop.
Save toxaq/7248280 to your computer and use it in GitHub Desktop.
Rails route dumping
<% Rails.application.routes.routes.map do |route| %>
<%
path = route.path.spec.to_s
next if path.starts_with? '/admin'
controller = route.defaults[:controller].to_s
action = route.defaults[:action].to_s
is_permitted = permitted_to? action.to_sym, controller.sub(/\//, '_').to_sym
%>
<tr><%#<td><%= route.name </td>%>
<td><%= path %></td>
<td><%# controller %><%= controller.sub(/\//, '_') %></td>
<td><%= action %></td>
<td style="color:#fff;background-color: <%=(is_permitted)? '#5BB75B' : '#DA4F49' %>"><%= (is_permitted) ? "Yes" : "No" %></td>
</tr>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment