Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add namespace support for authorization_usage

  • Loading branch information...
commit 27373691be91176dee5e182e1e5f4a4a508a1f2a 1 parent e891e44
@bterkuile bterkuile authored committed
View
2  app/views/authorization_usages/index.html.erb
@@ -17,7 +17,7 @@
<% @auth_usages_by_controller.keys.sort {|c1, c2| c1.name <=> c2.name}.each do |controller| %>
<% default_context = controller.controller_name.to_sym rescue nil %>
<tr>
- <th colspan="3"><%= h controller.controller_name %></th>
+ <th colspan="3"><%= h controller.name.underscore.sub(/_controller\Z/, '') %></th>
</tr>
<% @auth_usages_by_controller[controller].keys.sort {|c1, c2| c1.to_s <=> c2.to_s}.each do |action| %>
<% auth_info = @auth_usages_by_controller[controller][action] %>
View
9 lib/declarative_authorization/maintenance.rb
@@ -55,17 +55,14 @@ module Usage
def self.usages_by_controller
# load each application controller
begin
- Dir.foreach(File.join(::Rails.root, %w{app controllers})) do |entry|
- if entry =~ /^\w+_controller\.rb$/
- require File.join(::Rails.root, %w{app controllers}, entry)
- end
+ Dir.glob(File.join(::Rails.root, 'app', 'controllers', '**', '*_controller\.rb')) do |entry|
+ require entry
end
rescue Errno::ENOENT
end
controllers = []
ObjectSpace.each_object(Class) do |obj|
- controllers << obj if obj.ancestors.include?(ActionController::Base) and
- !%w{ActionController::Base ApplicationController}.include?(obj.name)
+ controllers << obj if obj.ancestors.include?(ActionController::Base) and obj != ActionController::Base and obj.name.demodulize != 'ApplicationController'
end
controllers.inject({}) do |memo, controller|
Please sign in to comment.
Something went wrong with that request. Please try again.