# Shared partial and controller helper

**URL:** <https://www.ruby-forum.com/t/shared-partial-and-controller-helper/125494>\
**Category:** Rails\
**Created:** [January 9, 2008, 5:17pm UTC](https://www.ruby-forum.com/t/shared-partial-and-controller-helper/125494 "2008-01-09T17:17:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rubeez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e480ec/32.png) [@rubeez](https://www.ruby-forum.com/u/rubeez)\
**Post date:** [January 9, 2008, 5:17pm UTC](https://www.ruby-forum.com/t/shared-partial-and-controller-helper/125494/1 "2008-01-09T17:17:57Z")

</div>

Hi all,

I have a shared partial that calls a helper function render\_foo.

I also have render\_foo defined in Control1Helper and Control2Helper  
(each slightly different)

However, rails seems to only use the render\_foo version in  
Controller1Helper even when I am responding from Controller2.

Is this a correct behavior?

Thanks.

–Tri

---

<div class="post-metadata">

**Author:** ![rubeez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e480ec/32.png) [@rubeez](https://www.ruby-forum.com/u/rubeez)\
**Post date:** [January 9, 2008, 5:41pm UTC](https://www.ruby-forum.com/t/shared-partial-and-controller-helper/125494/2 "2008-01-09T17:41:34Z")

</div>

On 9 Jan 2008, at 16:17, rubeez wrote:

> Hi all,
> 
> I have a shared partial that calls a helper function render\_foo.
> 
> I also have render\_foo defined in Control1Helper and Control2Helper  
> (each slightly different)
> 
> However, rails seems to only use the render\_foo version in  
> Controller1Helper even when I am responding from Controller2.

By default on rails 2.0 you’ll get helper :all in your application.rb  
So all helpers get loaded up into all views in all controllers, if 2  
of those modules end up defining a function with the same name then 1  
of those will win, and it will be the same thing for all controllers.  
You can get back the pre rails 2 behaviour by removing the helper :all

Fred

---

<div class="post-metadata">

**Author:** ![rubeez](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/e480ec/32.png) [@rubeez](https://www.ruby-forum.com/u/rubeez)\
**Post date:** [January 9, 2008, 5:42pm UTC](https://www.ruby-forum.com/t/shared-partial-and-controller-helper/125494/3 "2008-01-09T17:42:45Z")

</div>

Thanks, Fred…that fixes it.

On Jan 9, 9:41 am, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
