Last active
August 29, 2015 14:04
-
-
Save leompeters/39079af10483c1f6d096 to your computer and use it in GitHub Desktop.
List Rake Routes of your application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
-- Licensed under the MIT license [http://www.opensource.org/licenses/mit-license.php] | |
-- Copyright (c) 2013 by Belanton, Inc. All Rights Reserved. | |
--> | |
<html> | |
<head> | |
<title>Belanton | Codes | Scripts | Rake Routes</title> | |
<meta name="description" content="https://gist.github.com/leonardomarques/39079af10483c1f6d096"> | |
<meta name="keywords" content="Belanton,team,web,development,Ruby,Rails,ERB,HTML,rake,routes"> | |
<meta name="author" content="Leonardo Marques - Belanton Team [http://www.belanton.com]"> | |
</head> | |
<body> | |
<pre> | |
Rails.application.routes.routes.to_a.each do |rota| | |
if rota.app.instance_variable_defined? '@defaults' | |
perm = Permission.where({ | |
acao: rota.defaults[:action], | |
controller: rota.defaults[:controller], | |
verbo: rota.verb.source.to_s.gsub("^","").gsub("$","").downcase | |
).first_or_create | |
end | |
end | |
</pre> | |
<table class="table table-bordered"> | |
<tr> | |
<th><code>route.path.spec.to_s</code></th> | |
<th><code>route.defaults[:controller]</code></th> | |
<th><code>route.defaults[:action]</code></th> | |
<th><code>route.verb.source.to_s.gsub("^","").gsub("$","").downcase</code></th> | |
</tr> | |
<% Rails.application.routes.routes.each do |route| %> | |
<tr> | |
<td><%= route.path.spec.to_s %></td> | |
<td><%= route.defaults[:controller] %></td> | |
<td><%= route.defaults[:action] %></td> | |
<td><%= route.verb.source.to_s.gsub("^","").gsub("$","").downcase %></td> | |
</tr> | |
<% end %> | |
</table> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment