# Retrieve the current controller name from a view

**URL:** <https://www.ruby-forum.com/t/retrieve-the-current-controller-name-from-a-view/60552>\
**Category:** Rails\
**Created:** [May 15, 2006, 3:31pm UTC](https://www.ruby-forum.com/t/retrieve-the-current-controller-name-from-a-view/60552 "2006-05-15T15:31:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gael\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/bc8723/32.png) [@Gael\_P](https://www.ruby-forum.com/u/Gael_P)\
**Post date:** [May 15, 2006, 3:31pm UTC](https://www.ruby-forum.com/t/retrieve-the-current-controller-name-from-a-view/60552/1 "2006-05-15T15:31:27Z")

</div>

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.

Gael

---

<div class="post-metadata">

**Author:** ![Gael\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/bc8723/32.png) [@Gael\_P](https://www.ruby-forum.com/u/Gael_P)\
**Post date:** [May 15, 2006, 3:40pm UTC](https://www.ruby-forum.com/t/retrieve-the-current-controller-name-from-a-view/60552/2 "2006-05-15T15:40:53Z")

</div>

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

On 5/15/06, Gael P. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> * * *
> 
> Rails mailing list  
> removed\_email\_address@domain.invalid  
> [http://lists.rubyonrails.org/mailman/listinfo/rails](http://lists.rubyonrails.org/mailman/listinfo/rails)

–

---

<div class="post-metadata">

**Author:** ![Gael\_P](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/bc8723/32.png) [@Gael\_P](https://www.ruby-forum.com/u/Gael_P)\
**Post date:** [May 15, 2006, 3:47pm UTC](https://www.ruby-forum.com/t/retrieve-the-current-controller-name-from-a-view/60552/3 "2006-05-15T15:47:10Z")

</div>

Thanks, I knew it would be that simple…
