# How to read back what controller I am in?

**URL:** <https://www.ruby-forum.com/t/how-to-read-back-what-controller-i-am-in/90438>\
**Category:** Rails\
**Created:** [March 28, 2007, 9:32pm UTC](https://www.ruby-forum.com/t/how-to-read-back-what-controller-i-am-in/90438 "2007-03-28T21:32:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sean\_Lerner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@Sean\_Lerner](https://www.ruby-forum.com/u/Sean_Lerner)\
**Post date:** [March 28, 2007, 9:32pm UTC](https://www.ruby-forum.com/t/how-to-read-back-what-controller-i-am-in/90438/1 "2007-03-28T21:32:22Z")

</div>

Hello,

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:

\<%= WHATEVER\_SHOULD\_BE\_HERE %\>

then it would output:

display

thanks,

Sean

---

<div class="post-metadata">

**Author:** ![Sean\_Lerner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@Sean\_Lerner](https://www.ruby-forum.com/u/Sean_Lerner)\
**Post date:** [March 28, 2007, 9:38pm UTC](https://www.ruby-forum.com/t/how-to-read-back-what-controller-i-am-in/90438/2 "2007-03-28T21:38:23Z")

</div>

params[:controller] I believe.

Jason

---

<div class="post-metadata">

**Author:** ![Sean\_Lerner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@Sean\_Lerner](https://www.ruby-forum.com/u/Sean_Lerner)\
**Post date:** [March 28, 2007, 9:38pm UTC](https://www.ruby-forum.com/t/how-to-read-back-what-controller-i-am-in/90438/3 "2007-03-28T21:38:23Z")

</div>

\<%= controller.controller\_name %\>

Will print the name of the current controller.

Hope this helps,

– Paul

---

<div class="post-metadata">

**Author:** ![Sean\_Lerner](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/74df32/32.png) [@Sean\_Lerner](https://www.ruby-forum.com/u/Sean_Lerner)\
**Post date:** [March 28, 2007, 9:55pm UTC](https://www.ruby-forum.com/t/how-to-read-back-what-controller-i-am-in/90438/4 "2007-03-28T21:55:24Z")

</div>

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  
head.
