print out a controller's expected actions

Posted by jacqui maher on April 26, 2008 at 04:59 PM

Ever want to see a list of actions defined on your controller and what methods over http they expect?

try this in your console, where “users” is your controller’s name:

   1  ActionController::Routing::Routes.routes.select do |route|
2 route.defaults[:controller] == "users"
3 end.uniq.each do |route|
4 puts "#{route.defaults[:action]} expects http method: #{route.conditions[:method]}"
5 end;nil

Tags: meta, ruby
Hierarchy: previous, next

Comments

There are 0 comments on this post. Post yours →

Post a comment

Required fields in bold.