# Weakness of helper?

**URL:** <https://www.ruby-forum.com/t/weakness-of-helper/107104>\
**Category:** Rails\
**Created:** [June 18, 2007, 6:38am UTC](https://www.ruby-forum.com/t/weakness-of-helper/107104 "2007-06-18T06:38:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kevin\_Yang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a88e4f/32.png) [@Kevin\_Yang](https://www.ruby-forum.com/u/Kevin_Yang)\
**Post date:** [June 18, 2007, 6:38am UTC](https://www.ruby-forum.com/t/weakness-of-helper/107104/1 "2007-06-18T06:38:56Z")

</div>

Hi ,  
It comes to me that helper has some weaknesses:  
1) It is hard to test . No easy way to write test code for it.  
(or Just i didn’t know?)  
2) Not easy to reuse it on other controller/view/model.

```
  it looks like to that putting the helper code into a model (a

```

fully helper model , or a mixed model) is good practice.

```
  However i agree that some html intensive code still sites best

```

in helper .

```
 Any idea?

```

thanks  
Kevin

---

<div class="post-metadata">

**Author:** ![Kevin\_Yang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a88e4f/32.png) [@Kevin\_Yang](https://www.ruby-forum.com/u/Kevin_Yang)\
**Post date:** [June 26, 2007, 12:06pm UTC](https://www.ruby-forum.com/t/weakness-of-helper/107104/2 "2007-06-26T12:06:08Z")

</div>

Kevin Yang wrote:

> in helper .

1. You can test helpers, using TopFunky’s plugin (see  
[http://nubyonrails.com/articles/test-your-helpers](http://nubyonrails.com/articles/test-your-helpers)).

2. Well, you don’t generally want to reuse them in models - they are  
View helpers, after all.

There’s been some discussion about presenter patterns in models, but I  
don’t see a consensus appearing yet (and there’s way too much fu in  
those discussions for a relative amateur like me to have a view).

However, if you have a pattern which you genuinely need to have in both  
the controller and the helper (the current\_user is a classic example),  
you can define as a provate method in the controler and then make  
available to the view by calling helper :some\_method in the relevant  
controller

Cheers  
Chris

## –

[http://autopendium.com](http://autopendium.com)  
Stuff about old cars

---

<div class="post-metadata">

**Author:** ![Kevin\_Yang](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/a88e4f/32.png) [@Kevin\_Yang](https://www.ruby-forum.com/u/Kevin_Yang)\
**Post date:** [June 26, 2007, 12:10pm UTC](https://www.ruby-forum.com/t/weakness-of-helper/107104/3 "2007-06-26T12:10:08Z")

</div>

Chris T wrote:

> > ```
> > However i agree that some html intensive code still sites best
> > 
> > ```
> 
> However, if you have a pattern which you genuinely need to have in  
> both the controller and the helper (the current\_user is a classic  
> example), you can define as a provate method in the controler and then  
> make available to the view by calling helper :some\_method in the  
> relevant controller
> 
> Cheers  
> Chris

Sorry that should be helper\_method :some\_method  
Doh!

## –

[http://autopendium.com](http://autopendium.com)  
Stuff about old cars
