Getting the Controller name from a layout

I’m sure it’s a simple answer, but I’m trying to access which controller
a view is being displayed from within a layout. Basically what I want
to do is pull out the controller name from the URL.

For example:
/localhost/my_controller/new

I want to be able to get out ‘my_controller’ when my standard-layout is
generated, and from there render different menu items based on the
options that pertain to that particular controller.

Help would be appreciated, thanks in advance

I’m sure it’s a simple answer, but I’m trying to access which controller
a view is being displayed from within a layout. Basically what I want
to do is pull out the controller name from the URL.

For example:
/localhost/my_controller/new

I want to be able to get out ‘my_controller’ when my standard-layout is
generated, and from there render different menu items based on the
options that pertain to that particular controller.

params[:controller] should have it…

We put the below in our layout so we can view the source and see the
host,
controller, and action for any given page… sometimes it’s useful in
debugging.

controller.controller_name

On Aug 15, 10:06 am, Chris M. [email protected]

beauty, thanks. figured it was real simple!