Forum: Ruby on Rails Retrieve the current controller name from a view

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Gael P. (Guest)
on 2006-05-15 17:31
(Received via mailing list)
Hi all, I wonder if it's possible to retrieve the current controller
name and possibly the action when you're in a view.

i.e. I call the same template/partial view from different controllers
and I'd like to know when I'm in the view code which controller is
calling it...

Any ideas? Sorry if it's obvious but I couldn't find it in the doc.

Jón B. (Guest)
on 2006-05-15 17:40
(Received via mailing list)
<%= controller.controller_name -%>
<%= controller.action_name -%>

On 5/15/06, Gael P. <removed_email_address@domain.invalid> wrote:
> _______________________________________________
> Rails mailing list
> removed_email_address@domain.invalid

Gael P. (Guest)
on 2006-05-15 17:47
(Received via mailing list)
Thanks, I knew it would be that simple....
This topic is locked and can not be replied to.