Forum: Ruby on Rails How to read back what controller I am in?

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.
Sean Lerner (Guest)
on 2007-03-28 23:32
(Received via mailing list)

Is there a way I can determine in my .rhtml as to what controller is
currently being executed? (perhaps an environment variable?)

For example, if my controller is named "display", and I put:


then it would output:



Jason R. (Guest)
on 2007-03-28 23:38
(Received via mailing list)
params[:controller] I believe.

mudge (Guest)
on 2007-03-28 23:38
(Received via mailing list)
<%= controller.controller_name %>

Will print the name of the current controller.

Hope this helps,

-- Paul
Sean Lerner (Guest)
on 2007-03-28 23:55
(Received via mailing list)
Thanks... I realized it a few minutes after I posted -- it's been
staring me in the face all this time (that is params[:controller] =>
display in development mode). My head's cloudy this afternoon, and I
should know better than to post to the list for help with a cloudy
This topic is locked and can not be replied to.