DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

List All Controllers & Actions

07.26.2011
| 5809 views |
  • submit to reddit
        // description of your code here

controllers = Dir.new("#{RAILS_ROOT}/app/controllers").entries
controllers.each do |controller|
if controller =~ /_controller/
 cont = controller.camelize.gsub(".rb","")
 puts cont
 (eval("#{cont}.new.methods") -
   ApplicationController.methods -
   Object.methods - 
   ApplicationController.new.methods).sort.each {|met|
      puts "\t#{met}"
   }
end

end
    

Comments

Ross Jernigan replied on Wed, 2012/04/04 - 4:34pm

Thanks!