Hi, this blog is no longer maintained, my new blog is here

Ruby On Rails and a Conning Israeli entrepreneur

List all Controllers and actions

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}"



  Les Nightingill

July 22, 2008 at 1:00 AM

Elad, there's a problem with this code snippet...
If a controller has an action (e.g. "new") that is also in ActionController, then that action is not listed by this script. At this moment I'm not sure what the solution is. But I thought I'd mention it in case anyone else stumbles across this post.

  Elad Meidar

July 24, 2008 at 11:51 PM

That's right... thankx for pointing that out.

the solution is to handle application_controller seperatly from the other controllers, i am sure you can figure out from this code how to do it.
if not, you can always ask me :)

The Web Ask eizesus.com


    follow me on Twitter

    Twiters Around

    About Me

    My photo
    I am a web developer for more than 9 years, managed, cried, coded, designed and made money in this industry. now trying to do it again.