# Reuse code

**URL:** <https://www.ruby-forum.com/t/reuse-code/94712>\
**Category:** Rails\
**Created:** [May 11, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/reuse-code/94712 "2006-05-11T22:09:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ovidiu\_EFTIMIE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b9bd4f/32.png) [@Ovidiu\_EFTIMIE](https://www.ruby-forum.com/u/Ovidiu_EFTIMIE)\
**Post date:** [May 11, 2006, 10:09pm UTC](https://www.ruby-forum.com/t/reuse-code/94712/1 "2006-05-11T22:09:54Z")

</div>

Hi,  
I have several helper methods that I use on one view . Is there a way  
to share this methods on several views ?  
To be more specific in: companies\_helper I’ve defined the helper  
methods that I would like to use in products section.

Thanx,  
Ovidiu

---

<div class="post-metadata">

**Author:** ![Ovidiu\_EFTIMIE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b9bd4f/32.png) [@Ovidiu\_EFTIMIE](https://www.ruby-forum.com/u/Ovidiu_EFTIMIE)\
**Post date:** [May 11, 2006, 10:25pm UTC](https://www.ruby-forum.com/t/reuse-code/94712/2 "2006-05-11T22:25:45Z")

</div>

On 11 May 2006, at 9:06 pm, Ovidiu EFTIMIE wrote:

> Hi,  
> I have several helper methods that I use on one view . Is there a way  
> to share this methods on several views ?  
> To be more specific in: companies\_helper I’ve defined the helper  
> methods that I would like to use in products section.

I think all you have to do is something like this in your products  
controller, but I may be wrong:

class ProductsController \< ActionController  
helper :companies  
…

Either that, or if the methods are very generic, move them to  
application\_helper.

Kerry

---

<div class="post-metadata">

**Author:** ![Ovidiu\_EFTIMIE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/b9bd4f/32.png) [@Ovidiu\_EFTIMIE](https://www.ruby-forum.com/u/Ovidiu_EFTIMIE)\
**Post date:** [May 11, 2006, 10:35pm UTC](https://www.ruby-forum.com/t/reuse-code/94712/3 "2006-05-11T22:35:35Z")

</div>

Thanks Kerry . I’ll try that
