Accessing a controller variable?

I’m looking to find a way to access the data inside “@controller”.
i.e. when you have @controller.inspect you will see a list of all data
in them.

Are there anyway to do this?

My real aim is to get the name of the action automatically.

Parama wrote:

I’m looking to find a way to access the data inside “@controller”.
i.e. when you have @controller.inspect you will see a list of all data
in them.

Are there anyway to do this?

My real aim is to get the name of the action automatically.

if you have a class controller such as

ExampleController

you can access it by accessing it, really.
ruby-render this (the ExampleController class will need to exist
obviously):

ExampleController.methods.join(’ , ')

…and if you want it in a variable @controller, assign it.
@controller = ExampleController
and then, @controller.methods.inspect

hth

Hi –

On Sun, 17 Jun 2007, Parama wrote:

I’m looking to find a way to access the data inside “@controller”.
i.e. when you have @controller.inspect you will see a list of all data
in them.

Are there anyway to do this?

My real aim is to get the name of the action automatically.

Have a look at the docs for ActionController::Base. There’s an
attribute action_name, and various other methods for extracting
information.

David

Thanks David. it works