Can i know the name of my current controller in my views?

Just that: can i know the name of my current controller in my views?

I want to highlite in my main template (the one i use for all the pages)
the current page, to do that i need to know the current controller, and
i don’t want to use a controller variable with a before filter because i
think there should be a easiest way.

Emmanuel O. [email protected] wrote:

Just that: can i know the name of my current controller in my views?

The current controller is always in the “@controller” variable, so:

@controller.class.to_s

If you want the name as a string. If you just want to test if the
controller is a certain type use the “===” operator instead, eg;

if WidgetController === @controller
# running under widgetcontroller
else
# …
end

Cheers,
Tyler

umm… controller.controller_name might be a better solution.

for FooController you get ‘foo’

HTH
Trevor

On 6/13/07, Tyler MacDonald [email protected] wrote:

Trevor S.
http://somethinglearned.com