# Get method names?

**URL:** <https://www.ruby-forum.com/t/get-method-names/88515>\
**Category:** Rails\
**Created:** [March 12, 2007, 8:53am UTC](https://www.ruby-forum.com/t/get-method-names/88515 "2007-03-12T08:53:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sineserz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@sineserz](https://www.ruby-forum.com/u/sineserz)\
**Post date:** [March 12, 2007, 8:53am UTC](https://www.ruby-forum.com/t/get-method-names/88515/1 "2007-03-12T08:53:14Z")

</div>

hi all

I developed user management with roles and rights, what i need now is to  
build user management interface, to give roles and rights to user.

Is it possible to call controller and get all methods in a controller?  
is it possible to get all controller names ?

i think something like class.method\_names…

anybody?

thanks

serz

---

<div class="post-metadata">

**Author:** ![sineserz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@sineserz](https://www.ruby-forum.com/u/sineserz)\
**Post date:** [March 12, 2007, 10:54am UTC](https://www.ruby-forum.com/t/get-method-names/88515/2 "2007-03-12T10:54:03Z")

</div>

Hi

Can you use Module#instance\_methods ?  
For example admin\_controller.instance\_methods

burlight

On Mar 12, 2:53 pm, sine serz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![sineserz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@sineserz](https://www.ruby-forum.com/u/sineserz)\
**Post date:** [March 13, 2007, 8:22am UTC](https://www.ruby-forum.com/t/get-method-names/88515/3 "2007-03-13T08:22:46Z")

</div>

burlight wrote:

> Hi
> 
> Can you use Module#instance\_methods ?  
> For example admin\_controller.instance\_methods
> 
> burlight
> 
> On Mar 12, 2:53 pm, sine serz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

thanks burlight 😉

---

<div class="post-metadata">

**Author:** ![sineserz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@sineserz](https://www.ruby-forum.com/u/sineserz)\
**Post date:** [March 14, 2007, 9:16am UTC](https://www.ruby-forum.com/t/get-method-names/88515/4 "2007-03-14T09:16:27Z")

</div>

sine serz wrote:

> burlight wrote:
> 
> > Hi
> > 
> > Can you use Module#instance\_methods ?  
> > For example admin\_controller.instance\_methods
> > 
> > burlight
> > 
> > On Mar 12, 2:53 pm, sine serz [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
> 
> thanks burlight 😉

Module#instance\_methods, return all methods in a controller, but i only  
need my methods in a controller not system methods.  
Is it possible to get only def`s in a controller in some way?

What i was thinking is to open file then scan thru and pickup all  
methods.

but this is not nice.

Any1 have an Idea?

thanks

serz

---

<div class="post-metadata">

**Author:** ![sineserz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@sineserz](https://www.ruby-forum.com/u/sineserz)\
**Post date:** [March 14, 2007, 11:03am UTC](https://www.ruby-forum.com/t/get-method-names/88515/5 "2007-03-14T11:03:08Z")

</div>

Hi serz,

> Module#instance\_methods, return all methods in a controller,  
> but i only need my methods in a controller not system methods.  
> Is it possible to get only def`s in a controller in some way?
> 
> What i was thinking is to open file then scan thru and pickup all  
> methods.

See ActionController::Base.action\_methods and  
ActionController::Base#action\_methods

– Jean-François.

–  
Ruby ( [http://www.rubyfrance.org](http://www.rubyfrance.org) ) on Rails ( [http://www.railsfrance.org](http://www.railsfrance.org)  
)

---

<div class="post-metadata">

**Author:** ![sineserz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@sineserz](https://www.ruby-forum.com/u/sineserz)\
**Post date:** [March 14, 2007, 3:31pm UTC](https://www.ruby-forum.com/t/get-method-names/88515/6 "2007-03-14T15:31:10Z")

</div>

Jamal S. wrote:

> sine serz wrote:
> 
> > hi all
> > 
> > I developed user management with roles and rights, what i need now is to  
> > build user management interface, to give roles and rights to user.
> > 
> > Is it possible to call controller and get all methods in a controller?  
> > is it possible to get all controller names ?
> > 
> > i think something like class.method\_names…
> > 
> > anybody?
> > 
> > thanks
> > 
> > serz
> 
> Maybe give you another solution if you tell us why you need to get  
> output all the methods in the controller?

thanks all, controller.action\_methods works well.

I need this cause i am developing user management system, with roles and  
rights, so i need to call all action\_methods in a controller, so i could  
give rights to roles and users.

thanks again

---

<div class="post-metadata">

**Author:** ![sineserz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@sineserz](https://www.ruby-forum.com/u/sineserz)\
**Post date:** [March 14, 2007, 3:24pm UTC](https://www.ruby-forum.com/t/get-method-names/88515/7 "2007-03-14T15:24:04Z")

</div>

sine serz wrote:

> hi all
> 
> I developed user management with roles and rights, what i need now is to  
> build user management interface, to give roles and rights to user.
> 
> Is it possible to call controller and get all methods in a controller?  
> is it possible to get all controller names ?
> 
> i think something like class.method\_names…
> 
> anybody?
> 
> thanks
> 
> serz

Maybe give you another solution if you tell us why you need to get  
output all the methods in the controller?

---

<div class="post-metadata">

**Author:** ![sineserz](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ad7895/32.png) [@sineserz](https://www.ruby-forum.com/u/sineserz)\
**Post date:** [March 14, 2007, 4:05pm UTC](https://www.ruby-forum.com/t/get-method-names/88515/8 "2007-03-14T16:05:52Z")

</div>

sine serz wrote:

> Jamal S. wrote:
> 
> > sine serz wrote:
> > 
> > > hi all
> > > 
> > > I developed user management with roles and rights, what i need now is to  
> > > build user management interface, to give roles and rights to user.
> > > 
> > > Is it possible to call controller and get all methods in a controller?  
> > > is it possible to get all controller names ?
> > > 
> > > i think something like class.method\_names…
> > > 
> > > anybody?
> > > 
> > > thanks
> > > 
> > > serz
> > 
> > Maybe give you another solution if you tell us why you need to get  
> > output all the methods in the controller?
> 
> thanks all, controller.action\_methods works well.
> 
> I need this cause i am developing user management system, with roles and  
> rights, so i need to call all action\_methods in a controller, so i could  
> give rights to roles and users.
> 
> thanks again

I don’t know what you are trying to do exactly with the action\_methods,  
did you try to look at the before\_filter? you can use it in your  
controller, and give rights to certain methods for different user roles  
🙂

before\_filter :is\_admin, :only =\> %w{method methodto}
