I was recently overhauling my permissions for a big rails app and needed to see which filters were on which controllers as an overview. I came up with this little snippet which will go through each of your controllers and print out which filters are on them, as well as their options.
namespace :filters do
desc 'List all filter permissions'
task :list => :environment do
controllers = Dir[Rails.root.to_s+'/app/controllers/**/*_controller.rb'].map{ |f| File.basename(f).gsub(/\.rb$/, '').classify }.sort
controllers.each do |controller|
filters = controller.constantize.filter_chain
puts controller
filters.each do |filter|
puts "\t#{filter.method}"
puts "\t\t" << filter.options.inspect unless filter.options.blank?
end
puts
end
end
end
Outputs
ApplicationController
login_required
app_user_required
ClientsController
login_required
app_user_required
app_admin_required
{:only=>#<Set: {"edit", "update", "new", "create"}>}
super_admin_required
{:only=>#<Set: {"destroy"}>}
...
Now I can go through and see what permissions are too strict and which are too lenient and test accordingly.