Listing actions of the controller

Hi to all,

Is it possible to list out all the actions inside the controller.

Thanks in Advance
Saravanan

hi saravanan!

Saravanan Krishnan [2008-04-30 15:04]:

Is it possible to list out all the actions inside the controller.

YourController.public_instance_methods(false)

hth
jens

Hi --

Hi to all,

Is it possible to list out all the actions inside the controller.

I don't know whether there's anything higher lever, but from inside an
action try this:

   self.class.instance_methods(false)

It won't, of course, mention cases where you've got a template but no
action definition... but it's not such a bad idea to put empty actions
in your controller for those cases anyway. (At least, I like to.)

David

and how to get method in private, i run your scripts above, and they
only show public method. Thank you

Reinhart
Http://teapoci.blogspot.com

Visit Indonesia 2008 wrote:

and how to get method in private, i run your scripts above, and they
only show public method. Thank you

Reinhart
Http://teapoci.blogspot.com

to get method in private,
UploadController.private_instance_methods(false)

to get method in protected,
UploadController.protected_instance_methods(false)

This is how I did it once when I needed them as options for a select:

http://destiney.com/blog/rubyonrails-get-public-actions-from-a-controller

Hi --

Hi to all,

Is it possible to list out all the actions inside the controller.

I don't know whether there's anything higher lever, but from inside an
action try this:

  self.class.instance_methods(false)

Maybe SomeController.action_methods ? (subject of course to the same
caveats you give below)

Fred

Frederick Cheung [2008-04-30 16:35]:

Maybe SomeController.action_methods ?

this includes inherited and included methods as well (namely from
ApplicationController, which seems undesirable). OTOH, it respects
hidden actions. so, to combine the two:

  SomeController.public_instance_methods(false) -
SomeController.hidden_actions

oh, one more thing: if you have filter_parameter_logging in your
controller, filter_parameters will be added to that controller's
public instance methods.

cheers
jens

Hi --