Forum: Ruby on Rails Get method names?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D77663a5995b5538aa0bc62e6940e241?d=identicon&s=25 sine serz (sineserz)
on 2007-03-12 08:53
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
Ddc50fb60103da92d9561ead42ffb320?d=identicon&s=25 burlight (Guest)
on 2007-03-12 10:54
(Received via mailing list)
Hi

Can you use Module#instance_methods ?
For example admin_controller.instance_methods

burlight

On Mar 12, 2:53 pm, sine serz <rails-mailing-l...@andreas-s.net>
D77663a5995b5538aa0bc62e6940e241?d=identicon&s=25 sine serz (sineserz)
on 2007-03-13 08:22
burlight wrote:
> Hi
>
> Can you use Module#instance_methods ?
> For example admin_controller.instance_methods
>
> burlight
>
> On Mar 12, 2:53 pm, sine serz <rails-mailing-l...@andreas-s.net>

thanks burlight ;)
D77663a5995b5538aa0bc62e6940e241?d=identicon&s=25 sine serz (sineserz)
on 2007-03-14 09:16
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 <rails-mailing-l...@andreas-s.net>
>
> 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
A99870c1391c39da2089649745965bda?d=identicon&s=25 Jean-François Trân (Guest)
on 2007-03-14 11:03
(Received via mailing list)
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 ) on Rails ( http://www.railsfrance.org
)
E3513c4edd6810bb4b9914b58da2a2c3?d=identicon&s=25 Jamal Soueidan (jamal)
on 2007-03-14 15:24
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?
D77663a5995b5538aa0bc62e6940e241?d=identicon&s=25 sine serz (sineserz)
on 2007-03-14 15:31
Jamal Soueidan 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
E3513c4edd6810bb4b9914b58da2a2c3?d=identicon&s=25 Jamal Soueidan (jamal)
on 2007-03-14 16:05
sine serz wrote:
> Jamal Soueidan 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}
This topic is locked and can not be replied to.