# Which controller called my helper method?

**URL:** <https://www.ruby-forum.com/t/which-controller-called-my-helper-method/143370>\
**Category:** Rails\
**Created:** [July 17, 2008, 8:06pm UTC](https://www.ruby-forum.com/t/which-controller-called-my-helper-method/143370 "2008-07-17T20:06:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rpardee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@rpardee](https://www.ruby-forum.com/u/rpardee)\
**Post date:** [July 17, 2008, 8:06pm UTC](https://www.ruby-forum.com/t/which-controller-called-my-helper-method/143370/1 "2008-07-17T20:06:34Z")

</div>

Hey All,

Is there a global var or something that holds the name of the controller  
that called a given helper? I’m trying to re-use a partial, which calls  
a helper, and need to do something slightly different depending on which  
controller called the helper.

Thanks!

-Roy

Roy P.  
Research Analyst/Programmer  
Group Health Center For Health Studies (Cancer Research Network)  
(206) 287-2078  
Google Talk: rpardee

---

<div class="post-metadata">

**Author:** ![rpardee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@rpardee](https://www.ruby-forum.com/u/rpardee)\
**Post date:** [July 17, 2008, 8:10pm UTC](https://www.ruby-forum.com/t/which-controller-called-my-helper-method/143370/2 "2008-07-17T20:10:06Z")

</div>

controller and action are always in your params

If you can do params[:id] then you can do params[:controller] 🙂

---

<div class="post-metadata">

**Author:** ![rpardee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e47c2d/32.png) [@rpardee](https://www.ruby-forum.com/u/rpardee)\
**Post date:** [July 17, 2008, 8:14pm UTC](https://www.ruby-forum.com/t/which-controller-called-my-helper-method/143370/3 "2008-07-17T20:14:13Z")

</div>

Ah–and the params hash is accessible from my helper–bitchin’!

I’m set…

Thanks very much!.

* * *

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Brian H.  
Sent: Thursday, July 17, 2008 11:10 AM  
To: removed\_email\_address@domain.invalid  
Subject: [Rails] Re: which controller called my helper method?

controller and action are always in your params

If you can do params[:id] then you can do params[:controller] 🙂

On Thu, Jul 17, 2008 at 1:05 PM, Pardee, Roy [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

Hey All,

Is there a global var or something that holds the name of the  
controller  
that called a given helper? I’m trying to re-use a partial,  
which calls  
a helper, and need to do something slightly different depending  
on which  
controller called the helper.

Thanks!

-Roy

Roy P.  
Research Analyst/Programmer  
Group Health Center For Health Studies (Cancer Research Network)  
(206) 287-2078  
Google Talk: rpardee
