I’m trying to get a list of the methods that I’ve defined in a
controller. But,
“controller.methods” is giving me ALL the methods of the controller. Is
there a way to get the only the methods that I’ve defined?
Cheers
I’m trying to get a list of the methods that I’ve defined in a
controller. But,
“controller.methods” is giving me ALL the methods of the controller. Is
there a way to get the only the methods that I’ve defined?
Cheers
Luke :
I’m trying to get a list of the methods that I’ve defined in a
controller. But,“controller.methods” is giving me ALL the methods of the controller. Is
there a way to get the only the methods that I’ve defined?
ActionController::Base.action_methods and
ActionController::Base#action_methods give you a set
of your actions.
If you want the public methods defined just in your controller, you’ve
got MyController.public_instance_methods(false)
HTH,
-- Jean-François.
action_methods returns an array, and you can subtract one array from
another.
so to get just the actions for that controller, you could do this in
script/console:
MyController.action_methods - ApplicationController.action_methods
On Nov 26, 1:00 am, “Jean-François Trân” [email protected]
MyController.public_instance_methods(false)
Awesome, worked like a charm. Thanks.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs