Accessing a controller variable?


#1

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.


#2

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


#3

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


#4

Thanks David. it works